WP Table Builder – WordPress Table Plugin - Version 1.0.1

Version Description

  • NEW: Column Width Setting.
  • NEW: Row Height Setting.
Download this release

Release Info

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

Code changes from version 1.0.0 to 1.0.1

inc/admin/css/admin.css CHANGED
@@ -373,7 +373,7 @@ body>img {
373
  height: calc(100% - 89px);
374
  }
375
 
376
- #wptb-left-scroll-panel-curtain {
377
  position: absolute;
378
  top: 0;
379
  right: 0;
@@ -384,9 +384,16 @@ body>img {
384
  display: none;
385
  }
386
 
 
 
 
 
387
  #wptb-left-scroll-panel-curtain.visible {
388
  display: block;
389
  }
 
 
 
390
 
391
  #wptb-left-scroll-panel-curtain-close {
392
  margin: auto;
@@ -530,6 +537,11 @@ body>img {
530
  border-radius: 2px;
531
  }
532
 
 
 
 
 
 
533
  .wptb-settings-col-xs-8 {
534
  flex-basis: 66.66666667%;
535
  max-width: 66.66666667%;
@@ -699,6 +711,43 @@ input[type="range"]::-ms-thumb {
699
  transition: .25s;
700
  }
701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
 
703
  /**
704
  * Element Section
@@ -917,7 +966,6 @@ ul.wptb-tabs {
917
  position: relative;
918
  z-index: 1;
919
  margin: auto;
920
- padding: 2px;
921
  background: #fff;
922
  margin-top: 30px;
923
  margin-bottom: 30px;
@@ -1037,9 +1085,14 @@ table.wptb-table {
1037
  .wptb-preview-table {
1038
  table-layout: fixed;
1039
  font-size: 15px;
1040
- width: 100%;
1041
  display: table;
1042
- border-collapse: collapse;
 
 
 
 
 
 
1043
  }
1044
 
1045
  .wptb-preview-table.wptb-preview-table-manage-cells tbody>tr>td::after {
@@ -1062,6 +1115,7 @@ table.wptb-table {
1062
  font-size: 15px;
1063
  word-wrap: break-word;
1064
  overflow-wrap: break-word;
 
1065
  }
1066
 
1067
  .wptb-preview-table ul {
@@ -1085,10 +1139,13 @@ table.wptb-table {
1085
  .wptb-preview-table td {
1086
  padding: 15px;
1087
  position: relative;
1088
- width: 100px;
1089
  box-sizing: content-box;
1090
  }
1091
 
 
 
 
 
1092
  .wptb-preview-table .wptb-row td.wptb-highlighted,
1093
  .wptb-state-dragging td:hover {
1094
  outline: 1px solid lightgreen;
@@ -1435,7 +1492,7 @@ table.wptb-table {
1435
  .wptb-droppable.wptb-cell .wptb-directlyhovered {
1436
  border: 1px solid #1ea5e5 !important;
1437
  position: relative;
1438
- width: 100%;
1439
  }
1440
 
1441
  .wptb-droppable.wptb-cell .wptb-list-item-container.wptb-directlyhovered {
@@ -1485,6 +1542,7 @@ table.wptb-table {
1485
  height: 15px;
1486
  font-size: 9pt;
1487
  display: none;
 
1488
  }
1489
 
1490
  .wptb-ph-element:hover .wptb-actions {
373
  height: calc(100% - 89px);
374
  }
375
 
376
+ #wptb-left-scroll-panel-curtain, #wptb-left-scroll-panel-cell-settings {
377
  position: absolute;
378
  top: 0;
379
  right: 0;
384
  display: none;
385
  }
386
 
387
+ #wptb-left-scroll-panel-cell-settings {
388
+ padding: 0px;
389
+ }
390
+
391
  #wptb-left-scroll-panel-curtain.visible {
392
  display: block;
393
  }
394
+ #wptb-left-scroll-panel-cell-settings.visible {
395
+ display: block;
396
+ }
397
 
398
  #wptb-left-scroll-panel-curtain-close {
399
  margin: auto;
537
  border-radius: 2px;
538
  }
539
 
540
+ .wptb-settings-col-xs-12 {
541
+ flex-basis: 100%;
542
+ max-width: 100%;
543
+ }
544
+
545
  .wptb-settings-col-xs-8 {
546
  flex-basis: 66.66666667%;
547
  max-width: 66.66666667%;
711
  transition: .25s;
712
  }
713
 
714
+ .wptb-checkbox-button.wptb-column-width-fix-auto input:checked + i::after {
715
+ -webkit-transform: translateX(50px);
716
+ transform: translateX(50px);
717
+ }
718
+
719
+ .wptb-checkbox-button.wptb-column-width-fix-auto i {
720
+ float: left;
721
+ width: 100px;
722
+ border-radius: 5px;
723
+ height: 25px;
724
+ }
725
+
726
+ .wptb-checkbox-button.wptb-column-width-fix-auto i:after {
727
+ width: 50px;
728
+ height: 25px;
729
+ border-radius: 5px;
730
+ -webkit-transform: translateX(0px);
731
+ transform: translateX(0px);
732
+ }
733
+
734
+ .wptb-column-fixed, .wptb-column-auto {
735
+ position: absolute;
736
+ font-size: 15px;
737
+ width: 50%;
738
+ height: 100%;
739
+ text-align: center;
740
+ line-height: 25px;
741
+ }
742
+
743
+ .wptb-column-fixed {
744
+ color: #d8d9db;
745
+ }
746
+
747
+ .wptb-column-auto {
748
+ color: #3B7EC0;
749
+ right: 0;
750
+ }
751
 
752
  /**
753
  * Element Section
966
  position: relative;
967
  z-index: 1;
968
  margin: auto;
 
969
  background: #fff;
970
  margin-top: 30px;
971
  margin-bottom: 30px;
1085
  .wptb-preview-table {
1086
  table-layout: fixed;
1087
  font-size: 15px;
 
1088
  display: table;
1089
+ border-collapse: collapse !important;
1090
+ margin: auto;
1091
+ width: auto;
1092
+ }
1093
+
1094
+ .wptb-preview-table.wptb-preview-table-auto-width {
1095
+ width: auto;
1096
  }
1097
 
1098
  .wptb-preview-table.wptb-preview-table-manage-cells tbody>tr>td::after {
1115
  font-size: 15px;
1116
  word-wrap: break-word;
1117
  overflow-wrap: break-word;
1118
+ word-break: break-all;
1119
  }
1120
 
1121
  .wptb-preview-table ul {
1139
  .wptb-preview-table td {
1140
  padding: 15px;
1141
  position: relative;
 
1142
  box-sizing: content-box;
1143
  }
1144
 
1145
+ .wptb-preview-table td.wptb-td-default-width {
1146
+ width: 100px;
1147
+ }
1148
+
1149
  .wptb-preview-table .wptb-row td.wptb-highlighted,
1150
  .wptb-state-dragging td:hover {
1151
  outline: 1px solid lightgreen;
1492
  .wptb-droppable.wptb-cell .wptb-directlyhovered {
1493
  border: 1px solid #1ea5e5 !important;
1494
  position: relative;
1495
+ /*width: 100%;*/
1496
  }
1497
 
1498
  .wptb-droppable.wptb-cell .wptb-list-item-container.wptb-directlyhovered {
1542
  height: 15px;
1543
  font-size: 9pt;
1544
  display: none;
1545
+ min-width: 70px;
1546
  }
1547
 
1548
  .wptb-ph-element:hover .wptb-actions {
inc/admin/js/admin.js CHANGED
@@ -1,3 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  (function () {
2
  var WPTB_Builder = function WPTB_Builder() {
3
  var table_id = WPTB_Helper.detectMode();
@@ -230,6 +442,31 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
230
  getDOMElement().appendChild(node);
231
  };
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  return this;
234
  };
235
  var WPTB_DropHandle = function WPTB_DropHandle(thisElem, e) {
@@ -1134,7 +1371,6 @@ var WPTB_Helper = {
1134
  for (var j = 0; j < tdElements.length; j++) {
1135
  var element = tdElements[j];
1136
  if (element.classList.contains('wptb-ph-element')) {
1137
- var textContentStyle = element.getAttribute('style');
1138
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i);
1139
  if (infArr[1] == 'text') {
1140
  var p = element.querySelector('p'),
@@ -1219,6 +1455,28 @@ var WPTB_Helper = {
1219
  if (!results) return false;
1220
  if (!results[2]) return '';
1221
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222
  }
1223
  };
1224
  var WPTB_Image = function WPTB_Image(src, DOMElementProt) {
@@ -1322,27 +1580,119 @@ var WPTB_Initializer = function WPTB_Initializer() {
1322
  // WPTB_LeftPanel();
1323
  // }
1324
  };
1325
- var WPTB_LeftPanel = function WPTB_LeftPanel() {
1326
-
1327
- var table = document.getElementsByClassName('wptb-preview-table')[0],
1328
- wptbElementButtons = document.getElementsByClassName('wptb-element');
1329
 
1330
- function wptbTdBgColorSavedSet(inputId, trNumber) {
1331
- if (trNumber > 3) return;
1332
- if (table) {
1333
- var tableRows = table.getElementsByTagName('tr');
1334
- if (tableRows.length > trNumber) {
1335
- var trBackgroundColor = tableRows[trNumber].style.backgroundColor;
1336
- var wptbEvenRowBg = document.getElementById(inputId);
1337
- if (wptbEvenRowBg && trBackgroundColor) {
1338
- wptbEvenRowBg.value = WPTB_Helper.rgbToHex(trBackgroundColor);
1339
- }
1340
- }
1341
  }
1342
  }
1343
 
1344
- wptbTdBgColorSavedSet('wptb-even-row-bg', 1);
1345
- jQuery('#wptb-even-row-bg').wpColorPicker({
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1346
  change: function change(event, ui) {
1347
  var tableRows = table.getElementsByTagName('tr');
1348
  for (var _i = 1; _i < tableRows.length; _i += 2) {
@@ -1522,6 +1872,7 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
1522
  var tableCells = wptbPreviewTable[0].getElementsByTagName('td');
1523
  for (var i = 0; i < tableCells.length; i++) {
1524
  tableCells[i].style.border = '0px solid ' + color;
 
1525
  }
1526
  }
1527
  }
@@ -1593,19 +1944,28 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
1593
  var wptbImageWidthNumber = document.getElementById('wptb-image-width-number');
1594
  numberImputSize(wptbImageWidthNumber, 2, 100);
1595
 
 
 
 
 
 
 
1596
  document.getElementById('wptb-table-cell-slider').oninput = function () {
1597
  document.getElementById('wptb-table-cell-number').value = this.value;
1598
  addCellPadding(this.value);
 
1599
  };
1600
 
1601
  document.getElementById('wptb-table-cell-number').onchange = function () {
1602
  document.getElementById('wptb-table-cell-slider').value = this.value;
1603
  addCellPadding(this.value);
 
1604
  };
1605
 
1606
  document.getElementById('wptb-table-border-slider').oninput = function () {
1607
  document.getElementById('wptb-table-border-number').value = this.value;
1608
  addBorderSize(this.value);
 
1609
 
1610
  var wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,
1611
  tableBorderColorSetArea = document.getElementById('wptb-table-border-color-set-area');
@@ -1619,16 +1979,19 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
1619
  document.getElementById('wptb-table-border-number').onchange = function () {
1620
  document.getElementById('wptb-table-border-slider').value = this.value;
1621
  addBorderSize(this.value);
 
1622
  };
1623
 
1624
  document.getElementById('wptb-table-inner-border-slider').oninput = function () {
1625
  document.getElementById('wptb-table-inner-border-number').value = this.value;
1626
  addInnerBorderSize(this.value);
 
1627
  };
1628
 
1629
  document.getElementById('wptb-table-inner-border-number').onchange = function () {
1630
  document.getElementById('wptb-table-inner-border-slider').value = this.value;
1631
  addInnerBorderSize(this.value);
 
1632
  };
1633
 
1634
  document.getElementById('wptb-inner-border-check').onchange = function () {
@@ -1645,6 +2008,54 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
1645
  }
1646
  };
1647
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1648
  function createMobileHeadForTable(table, thisEvent) {
1649
 
1650
  if (thisEvent.checked) {
@@ -2181,19 +2592,14 @@ var WPTB_Stringifier = function WPTB_Stringifier(codeMain) {
2181
  var code = codeMain.cloneNode(true);
2182
  code.classList.add('wptb-table-preview-static-indic');
2183
  code.dataset.tableColumns = codeMain.columns;
2184
- code.dataset.reconstraction = 1;
 
 
2185
 
2186
  var tds = code.getElementsByTagName('td');
2187
  if (tds.length > 0) {
2188
  for (var i = 0; i < tds.length; i++) {
2189
 
2190
- for (var _i = 0; _i < tds.length; _i++) {
2191
- if (code.dataset.reconstraction == 1 && tds[_i].colSpan > 1 || tds[_i].rowSpan > 1) {
2192
- code.dataset.reconstraction = 0;
2193
- break;
2194
- }
2195
- }
2196
-
2197
  if (codeMain.querySelector('wptb-table-preview-head')) {
2198
  tds[i].removeAttribute('data-x-index');
2199
  }
@@ -2353,6 +2759,7 @@ var array = [],
2353
  noCells = document.getElementsByClassName('wptb-no-cell-action'),
2354
  singleCells = document.getElementsByClassName('wptb-single-action'),
2355
  multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),
 
2356
  position = getCoords(this),
2357
  row = position[0],
2358
  column = position[1];
@@ -2389,6 +2796,7 @@ var array = [],
2389
  singleCells[i].classList.remove('visible');
2390
  singleCells[i].setAttribute('disabled', 'disabled');
2391
  }
 
2392
  } else if (markedCells === 1) {
2393
  for (var i = 0; i < multipleCells.length; i++) {
2394
  multipleCells[i].classList.remove('visible');
@@ -2402,6 +2810,47 @@ var array = [],
2402
  singleCells[i].classList.add('visible');
2403
  singleCells[i].removeAttribute('disabled');
2404
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2405
  } else {
2406
  for (var i = 0; i < multipleCells.length; i++) {
2407
  if (table.isSquare(array)) {
@@ -2420,6 +2869,7 @@ var array = [],
2420
  singleCells[i].classList.remove('visible');
2421
  singleCells[i].setAttribute('disabled', 'disabled');
2422
  }
 
2423
  }
2424
  };
2425
 
@@ -2677,8 +3127,8 @@ var array = [],
2677
 
2678
  //Create a HTML Table element.
2679
  table = document.createElement('table');
2680
- table.classList.add('wptb-preview-table');
2681
-
2682
  //Add the data rows.
2683
  for (var i = 0; i < rows; i++) {
2684
 
@@ -2716,6 +3166,7 @@ var array = [],
2716
  var bar = document.getElementsByClassName('wptb-edit-bar'),
2717
  cellModeBackground = document.getElementById('wptb-cell_mode_background'),
2718
  leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
 
2719
  wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
2720
  if (wptbPreviewTable.length > 0) {
2721
  wptbPreviewTable = wptbPreviewTable[0];
@@ -2728,6 +3179,7 @@ var array = [],
2728
  bar[_i2].classList.remove('visible');
2729
  cellModeBackground.classList.remove('visible');
2730
  leftScrollPanelCurtain.classList.remove('visible');
 
2731
  wptbPreviewTable.classList.remove('wptb-preview-table-manage-cells');
2732
  var wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');
2733
  if (wptbPreviewTableTds.length > 0) {
@@ -2755,6 +3207,7 @@ var array = [],
2755
  var trs = this.getElementsByTagName('tr'),
2756
  tds = void 0,
2757
  maxCols = 0,
 
2758
  tdsArr = [];
2759
  var wptbTopRowAsHeader = document.getElementById('wptb-top-row-as-header');
2760
 
@@ -2831,12 +3284,308 @@ var array = [],
2831
  }
2832
  }
2833
  jMainIter++;
 
 
 
2834
  }
2835
  if (j > maxCols) {
2836
  maxCols = j;
2837
  }
2838
  }
2839
  this.columns = maxCols;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2840
  };
2841
 
2842
  /*
@@ -2854,16 +3603,23 @@ var array = [],
2854
  if (currentTableTd) {
2855
  currentTdStyle = currentTableTd.getAttribute('style');
2856
  }
 
2857
  for (var i = 0; i < table.rows.length; i++) {
2858
  td = new WPTB_Cell(mark);
 
2859
  if (currentTdStyle) {
2860
  td.getDOMElement().setAttribute('style', currentTdStyle);
 
2861
  }
 
2862
  table.rows[i].appendChild(td.getDOMElement());
2863
  array[i].push(0);
2864
  }
 
2865
  maxAmountOfCells++;
2866
  table.recalculateIndexes();
 
 
2867
  WPTB_Helper.dataTitleColumnSet(table);
2868
  undoSelect();
2869
  };
@@ -2885,10 +3641,12 @@ var array = [],
2885
  if (currentTableTd) {
2886
  currentTdStyle = currentTableTd.getAttribute('style');
2887
  }
 
2888
  for (var i = 0; i < table.rows.length; i++) {
2889
  td = new WPTB_Cell(mark);
2890
  if (currentTdStyle) {
2891
  td.getDOMElement().setAttribute('style', currentTdStyle);
 
2892
  }
2893
  firstCell = table.rows[i].getElementsByTagName('td')[0];
2894
  if (firstCell) {
@@ -2901,6 +3659,8 @@ var array = [],
2901
 
2902
  maxAmountOfCells++;
2903
  table.recalculateIndexes();
 
 
2904
  WPTB_Helper.dataTitleColumnSet(table);
2905
  undoSelect();
2906
  };
@@ -2945,6 +3705,7 @@ var array = [],
2945
  td = new WPTB_Cell(mark);
2946
  if (cellStyle) {
2947
  td.getDOMElement().setAttribute('style', cellStyle);
 
2948
  }
2949
  if (currentCell && rows[i].contains(currentCell)) {
2950
  bro = currentCell.nextSibling;
@@ -2996,6 +3757,8 @@ var array = [],
2996
  maxAmountOfCells++;
2997
  drawTable(array);
2998
  table.recalculateIndexes();
 
 
2999
  WPTB_Helper.dataTitleColumnSet(table);
3000
  undoSelect();
3001
  }
@@ -3051,6 +3814,7 @@ var array = [],
3051
  array.push(aux);
3052
  drawTable(array);
3053
  table.recalculateIndexes();
 
3054
  WPTB_Helper.dataTitleColumnSet(table);
3055
  undoSelect();
3056
  };
@@ -3087,6 +3851,7 @@ var array = [],
3087
  array.push(aux);
3088
  drawTable(array);
3089
  table.recalculateIndexes();
 
3090
  WPTB_Helper.dataTitleColumnSet(table);
3091
  undoSelect();
3092
  };
@@ -3102,13 +3867,13 @@ var array = [],
3102
  cellStyle = cell.getAttribute('style'),
3103
  row = getCoords(cell)[0],
3104
  cellNew = void 0;
3105
- for (var _i4 = row - 1; _i4 >= 0; _i4--) {
3106
- var rowChildren = table.rows[_i4].children;
3107
  var rowChildrenLength = rowChildren.length;
3108
  if (rowChildrenLength > 0) {
3109
- for (var _j = 0; _j < rowChildrenLength; _j++) {
3110
- if (rowChildren[_j].rowSpan == 1) {
3111
- row = _i4;
3112
  cellNew = true;
3113
  break;
3114
  }
@@ -3150,15 +3915,15 @@ var array = [],
3150
 
3151
  var cellsColSpan = 0;
3152
  if (rowAfter < table.rows.length - 1) {
3153
- for (var _i5 = 0; _i5 <= rowAfter; _i5++) {
3154
- var tableRowsIChildren = table.rows[_i5].children,
3155
  tableRIChildrenLength = tableRowsIChildren.length;
3156
  if (tableRIChildrenLength > 0) {
3157
- for (var _j2 = 0; _j2 < tableRIChildrenLength; _j2++) {
3158
- var rowIRowSpan = tableRowsIChildren[_j2].rowSpan;
3159
 
3160
- if (rowIRowSpan - 1 + _i5 > rowAfter) {
3161
- tableRowsIChildren[_j2].rowSpan++;
3162
  }
3163
  }
3164
  }
@@ -3169,8 +3934,8 @@ var array = [],
3169
  rNextChildrenLength = rNextChildren.length;
3170
 
3171
  if (rNextChildrenLength > 0) {
3172
- for (var _i6 = 0; _i6 < rNextChildrenLength; _i6++) {
3173
- cellsColSpan += rNextChildren[_i6].colSpan;
3174
  }
3175
  }
3176
  } else {
@@ -3183,6 +3948,8 @@ var array = [],
3183
  for (j = 0; j < cellsColSpan; j++) {
3184
  var td = new WPTB_Cell(mark);
3185
  td.getDOMElement().setAttribute('style', cellStyle);
 
 
3186
  r.appendChild(td.getDOMElement());
3187
  }
3188
 
@@ -3190,6 +3957,7 @@ var array = [],
3190
  array.push(aux);
3191
  drawTable(array);
3192
  table.recalculateIndexes();
 
3193
  WPTB_Helper.dataTitleColumnSet(table);
3194
  undoSelect();
3195
  };
@@ -3278,26 +4046,46 @@ var array = [],
3278
  tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),
3279
  tdsChildrenNew = [];
3280
 
3281
- for (var _i7 = 0; _i7 < tds.length; _i7++) {
3282
- var tdsInternalElements = tds[_i7].getElementsByClassName('wptb-ph-element');
3283
  if (tdsInternalElements.length > 0) {
3284
  var tdsIntElemLength = tdsInternalElements.length;
3285
- for (var _j3 = 0; _j3 < tdsIntElemLength; _j3++) {
3286
- tdsChildrenNew.push(tdsInternalElements[_j3]);
3287
  }
3288
  }
3289
- var p = tds[_i7].parentNode;
3290
- p.removeChild(tds[_i7]);
3291
  }
3292
  if (tdsChildrenNew.length > 0) {
3293
- for (var _i8 = 0; _i8 < tdsChildrenNew.length; _i8++) {
3294
- first.appendChild(tdsChildrenNew[_i8]);
3295
  }
3296
  }
3297
 
3298
  first.colSpan = colspan;
3299
  first.rowSpan = rowspan;
3300
  table.recalculateIndexes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3301
  WPTB_Helper.dataTitleColumnSet(table);
3302
  undoSelect();
3303
  };
@@ -3321,9 +4109,10 @@ var array = [],
3321
  cell.rowSpan = 1;
3322
  cell.colSpan = 1;
3323
 
3324
- for (var _i9 = 1; _i9 < colspan; _i9++) {
3325
  var td = new WPTB_Cell(mark);
3326
  td.getDOMElement().setAttribute('style', cellStyles);
 
3327
  if (cell.nextSibling) {
3328
  thisRow.insertBefore(td.getDOMElement(), cell.nextSibling);
3329
  } else {
@@ -3332,21 +4121,21 @@ var array = [],
3332
  }
3333
 
3334
  if (rowspan > 1) {
3335
- for (var _i10 = 1; _i10 < rowspan; _i10++) {
3336
  var rowChildInsertBefore = undefined,
3337
- rowNext = table.rows[row + _i10],
3338
  rowChildren = rowNext.children,
3339
  rowChildrenLength = rowChildren.length;
3340
 
3341
  if (rowChildrenLength > 0) {
3342
- for (var _k3 = 0; _k3 < rowChildrenLength; _k3++) {
3343
- if (Number(rowChildren[_k3].dataset.xIndex) > Number(cellXIndex)) {
3344
- rowChildInsertBefore = rowChildren[_k3];
3345
  break;
3346
  }
3347
  }
3348
  }
3349
- for (var _j4 = 0; _j4 < colspan; _j4++) {
3350
  var _td = new WPTB_Cell(mark);
3351
  _td.getDOMElement().setAttribute('style', cellStyles);
3352
  if (rowChildInsertBefore != undefined) {
@@ -3359,6 +4148,9 @@ var array = [],
3359
  }
3360
 
3361
  table.recalculateIndexes();
 
 
 
3362
  WPTB_Helper.dataTitleColumnSet(table);
3363
  undoSelect();
3364
  };
@@ -3444,7 +4236,7 @@ var array = [],
3444
 
3445
  if (rowspan == undefined) rowspan = 1;
3446
 
3447
- for (var _i11 = 0; _i11 < rowspan; _i11++) {
3448
  thisRow = table.rows[row];
3449
  var thisRowChildren = thisRow.children,
3450
  nextRow = table.rows[row + 1],
@@ -3455,17 +4247,17 @@ var array = [],
3455
  if (nextRow != undefined) {
3456
  nextRowChildren = nextRow.children;
3457
  nextRowChildrenLength = nextRowChildren.length;
3458
- for (var _j5 = 0; _j5 < thisRowChildren.length; _j5++) {
3459
- if (thisRowChildren[_j5].rowSpan > 1) {
3460
  var td = new WPTB_Cell(mark);
3461
  td.getDOMElement().setAttribute('style', cellStyles);
3462
- td.getDOMElement().colSpan = thisRowChildren[_j5].colSpan;
3463
- td.getDOMElement().rowSpan = thisRowChildren[_j5].rowSpan - 1;
3464
 
3465
  var nextRowChildrenK = undefined;
3466
- for (var _k4 = 0; _k4 < nextRowChildrenLength; _k4++) {
3467
- if (Number(nextRowChildren[_k4].dataset.xIndex) > Number(thisRowChildren[_j5].dataset.xIndex)) {
3468
- nextRowChildrenK = nextRowChildren[_k4];
3469
  break;
3470
  }
3471
  }
@@ -3479,11 +4271,11 @@ var array = [],
3479
  }
3480
 
3481
  if (tdArr.length > 0) {
3482
- for (var _k5 = 0; _k5 < tdArr.length; _k5++) {
3483
- if (tdArr[_k5][1] != undefined) {
3484
- nextRow.insertBefore(tdArr[_k5][0].getDOMElement(), tdArr[_k5][1]);
3485
  } else {
3486
- nextRow.appendChild(tdArr[_k5][0].getDOMElement());
3487
  }
3488
  }
3489
  }
@@ -3491,11 +4283,11 @@ var array = [],
3491
 
3492
  var tableRows = table.rows;
3493
  if (tableRows.length > 0) {
3494
- for (var _j6 = 0; _j6 < row; _j6++) {
3495
- var jRowChildren = tableRows[_j6].children;
3496
  if (jRowChildren.length > 0) {
3497
  for (var x = 0; x < jRowChildren.length; x++) {
3498
- if (jRowChildren[x].rowSpan - 1 >= row - _j6) {
3499
  jRowChildren[x].rowSpan--;
3500
  }
3501
  }
@@ -3531,22 +4323,22 @@ var array = [],
3531
  cellXIndex = cell.dataset.xIndex,
3532
  colspan = cell.colSpan;
3533
 
3534
- for (var _i12 = 0; _i12 < colspan; _i12++) {
3535
- for (var _j7 = 0; _j7 < table.rows.length; _j7++) {
3536
- var rowChildren = table.rows[_j7].children;
3537
  var rowChildrenLength = rowChildren.length;
3538
  if (rowChildrenLength > 0) {
3539
- for (var _k6 = rowChildrenLength - 1; _k6 >= 0; _k6--) {
3540
- if (Number(rowChildren[_k6].dataset.xIndex) == Number(cellXIndex)) {
3541
- if (rowChildren[_k6].colSpan > 1) {
3542
- rowChildren[_k6].colSpan--;
3543
  } else {
3544
- table.rows[_j7].removeChild(rowChildren[_k6]);
3545
  }
3546
  break;
3547
- } else if (Number(rowChildren[_k6].dataset.xIndex) < Number(cellXIndex) && Number(rowChildren[_k6].dataset.xIndex) + Number(rowChildren[_k6].colSpan - 1) >= cellXIndex) {
3548
- if (rowChildren[_k6].colSpan > 1) {
3549
- rowChildren[_k6].colSpan--;
3550
  }
3551
  break;
3552
  }
@@ -3554,8 +4346,8 @@ var array = [],
3554
  }
3555
  }
3556
 
3557
- for (var _j8 = 0; _j8 < table.rows.length; _j8++) {
3558
- if (array[_j8] != undefined) array[_j8].pop();
3559
  }
3560
 
3561
  maxAmountOfCells--;
@@ -3568,6 +4360,7 @@ var array = [],
3568
  }
3569
 
3570
  table.recalculateIndexes();
 
3571
  WPTB_Helper.dataTitleColumnSet(table);
3572
  }
3573
  undoSelect();
@@ -3584,6 +4377,12 @@ var array = [],
3584
  //if (columns || rows) {
3585
  table.recalculateIndexes(true);
3586
  //}
 
 
 
 
 
 
3587
 
3588
  WPTB_LeftPanel();
3589
 
@@ -3656,308 +4455,4 @@ var WPTB_Text = function WPTB_Text(text, DOMElementProt) {
3656
 
3657
  return this;
3658
  };
3659
- var WPTB_innerElementSet = function WPTB_innerElementSet(element) {
3660
-
3661
- function newElementProxy(el) {
3662
- if (el == 'list') {
3663
- return new WPTB_List();
3664
- } else if (el == 'image') {
3665
- return new WPTB_Image();
3666
- } else if (el == 'text') {
3667
- return new WPTB_Text();
3668
- } else if (el == 'button') {
3669
- return new WPTB_Button();
3670
- }
3671
- }
3672
-
3673
- element.ondragenter = function (e) {
3674
- var div;
3675
- if (e.dataTransfer.types.indexOf('wptbelement') == -1 && e.dataTransfer.types.indexOf('wptb-moving-mode') == -1) {
3676
- return;
3677
- }
3678
- WPTB_DropHandle(this, e);
3679
-
3680
- element.classList.add('wptb-ondragenter');
3681
- };
3682
- element.ondragover = function (e) {
3683
- e.preventDefault();
3684
- WPTB_DropHandle(this, e);
3685
- };
3686
- element.ondragleave = function () {};
3687
- element.ondrop = function (e) {
3688
- this.classList.remove('wptb-ondragenter');
3689
- var element = void 0,
3690
- classId = void 0;
3691
- e.preventDefault();
3692
- e.stopPropagation();
3693
-
3694
- if (!e.dataTransfer.getData('wptbElement') && !e.dataTransfer.getData('node')) {
3695
- return;
3696
- }
3697
- var wptbDropHandle = void 0,
3698
- wptbDropBorderMarker = void 0;
3699
- if (document.getElementsByClassName('wptb-drop-handle').length > 0) {
3700
- wptbDropHandle = document.getElementsByClassName('wptb-drop-handle')[0];
3701
- }
3702
- if (document.getElementsByClassName('wptb-drop-border-marker').length > 0) {
3703
- wptbDropBorderMarker = document.getElementsByClassName('wptb-drop-border-marker')[0];
3704
- }
3705
-
3706
- if (e.dataTransfer.getData('wptbElement')) {
3707
- element = newElementProxy(e.dataTransfer.getData('wptbElement'));
3708
- element = element.getDOMElement();
3709
- } else {
3710
- classId = e.dataTransfer.getData('node');
3711
- element = document.getElementsByClassName(classId)[0];
3712
- element.classList.remove('wptb-moving-mode');
3713
- }
3714
-
3715
- if (wptbDropHandle.style.display == 'block') {
3716
- var td = void 0;
3717
- if (wptbDropHandle.dataset.text == 'Drop Here') {
3718
- td = wptbDropHandle.getDOMParentElement();
3719
- td.appendChild(element);
3720
- } else {
3721
- var innerElement = wptbDropHandle.getDOMParentElement();
3722
- td = innerElement.parentNode;
3723
-
3724
- if (wptbDropHandle.dataset.text == 'Abowe Element') {
3725
- td.insertBefore(element, innerElement);
3726
- } else if (wptbDropHandle.dataset.text == 'Below Element') {
3727
- var innerElementNext = innerElement.nextSibling;
3728
- td.insertBefore(element, innerElementNext);
3729
- }
3730
- }
3731
- var thisRow = td.parentNode;
3732
- if (thisRow.classList.contains('wptb-table-head')) {
3733
- var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
3734
- WPTB_Helper.dataTitleColumnSet(table);
3735
- }
3736
- } else {
3737
- return;
3738
- }
3739
-
3740
- wptbDropHandle.style.display = 'none';
3741
- wptbDropBorderMarker.style.display = 'none';
3742
-
3743
- WPTB_innerElementSet(element);
3744
-
3745
- return true;
3746
- };
3747
- element.onmouseover = function (e) {
3748
- element.classList.remove('wptb-ondragenter');
3749
- };
3750
- };
3751
- var applyGenericItemSettings = function applyGenericItemSettings(element, kindIndexProt) {
3752
- var copy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3753
-
3754
- var node = element.getDOMElement(),
3755
- index,
3756
- listItems,
3757
- copy;
3758
-
3759
- if (kindIndexProt == undefined || copy == true) {
3760
- index = document.counter.nextIndex(element.kind);
3761
- var wptbElements = document.getElementsByClassName('wptb-ph-element');
3762
- var elementIndexesArr = [];
3763
- for (var i = 0; i < wptbElements.length; i++) {
3764
- var regex = new RegExp('wptb-element-' + element.kind + '-(\\d+)', "i");
3765
- var infArr = wptbElements[i].className.match(regex);
3766
- if (infArr) {
3767
- elementIndexesArr.push(infArr[1]);
3768
- }
3769
- }
3770
- if (elementIndexesArr.length > 0) {
3771
- var elementIndexMax = Math.max.apply(Math, elementIndexesArr);
3772
- index = elementIndexMax + 1;
3773
- } else {
3774
- index = 1;
3775
- }
3776
- } else if (kindIndexProt && !copy) {
3777
- index = kindIndexProt.split('-')[1];
3778
- }
3779
-
3780
- node.onmouseenter = function (event) {
3781
- this.classList.add('wptb-directlyhovered');
3782
- var btnDelete = document.createElement('span'),
3783
- btnCopy = document.createElement('span'),
3784
- btnMove = document.createElement('span'),
3785
- actions = document.createElement('span'),
3786
- i = void 0;
3787
-
3788
- actions.classList.add('wptb-actions');
3789
- btnDelete.classList.add('dashicons', 'dashicons-trash', 'wptb-delete-action');
3790
- btnCopy.classList.add('dashicons', 'dashicons-admin-page', 'wptb-duplicate-action');
3791
- btnMove.classList.add("dashicons", "dashicons-move", 'wptb-move-action');
3792
- btnMove.draggable = true;
3793
- btnDelete.onclick = function (event) {
3794
- var act = this.parentNode.parentNode,
3795
- el = act.parentNode;
3796
- el.removeChild(act);
3797
-
3798
- if (act.kind == 'text') {
3799
- var thisRow = el.parentNode;
3800
- if (thisRow.classList.contains('wptb-table-head')) {
3801
- var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
3802
- WPTB_Helper.dataTitleColumnSet(table);
3803
- }
3804
- }
3805
- };
3806
- btnCopy.onclick = function (event) {
3807
- var copy = void 0;
3808
- if (element.kind == 'list') {
3809
- var td = event.target.parentNode.parentNode.parentNode,
3810
- temp = [],
3811
- srcList = event.target.parentNode.parentNode.querySelectorAll('ul li .wptb-list-item-content');
3812
-
3813
- for (var i = 0; i < srcList.length; i++) {
3814
- temp.push(srcList[i].innerHTML);
3815
- }
3816
-
3817
- copy = new WPTB_List(temp, node);
3818
-
3819
- node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
3820
- } else if (element.kind == 'text') {
3821
- var td = event.target.parentNode.parentNode.parentNode;
3822
- copy = new WPTB_Text(event.target.parentNode.parentNode.childNodes[0].innerHTML, node);
3823
-
3824
- node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
3825
- } else if (element.kind == 'image') {
3826
- var td = event.target.parentNode.parentNode.parentNode;
3827
- copy = new WPTB_Image(event.target.parentNode.parentNode.children[0].children[0].src, node);
3828
-
3829
- node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
3830
- } else {
3831
- var td = event.target.parentNode.parentNode.parentNode,
3832
- text = event.target.parentNode.parentNode.childNodes[0].querySelector('p').innerHTML;
3833
- copy = new WPTB_Button(text, node);
3834
-
3835
- node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
3836
- }
3837
-
3838
- WPTB_innerElementSet(copy.getDOMElement());
3839
- };
3840
- var parent = this,
3841
- infArr = void 0,
3842
- type = void 0;
3843
- infArr = parent.className.match(/wptb-element-(.+)-(\d+)/i);
3844
- type = infArr[1];
3845
- var dragImagesArr = WPTB_Helper.dragImagesArr();
3846
- btnMove.ondragstart = function (event) {
3847
- this.parentNode.style.opacity = 0;
3848
- parent.classList.remove('wptb-directlyhovered');
3849
- parent.classList.add('wptb-moving-mode');
3850
-
3851
- event.dataTransfer.setDragImage(dragImagesArr[type], 0, 0);
3852
- event.dataTransfer.setData('node', 'wptb-element-' + infArr[1] + '-' + infArr[2]);
3853
- event.dataTransfer.setData('wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2]);
3854
- event.dataTransfer.setData('wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1]);
3855
- var act = event.target.parentNode.parentNode;
3856
- if (act.kind == 'text') {
3857
- var thisRow = el.parentNode;
3858
- if (thisRow.classList.contains('wptb-table-head')) {
3859
- var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
3860
- WPTB_Helper.dataTitleColumnSet(table);
3861
- }
3862
- }
3863
- };
3864
-
3865
- if (element.kind === 'button') {
3866
- var a = node.querySelector('a'),
3867
- target = a.querySelector('div');
3868
- a.onclick = function (e) {
3869
- e.preventDefault();
3870
- };
3871
- WPTB_Helper.buttonsTinyMceInit(target);
3872
- } else if (element.kind === 'text') {
3873
- tinyMCE.init({
3874
- target: node.childNodes[0],
3875
- inline: true,
3876
- plugins: "link, paste",
3877
- dialog_type: "modal",
3878
- theme: 'modern',
3879
- menubar: false,
3880
- fixed_toolbar_container: '#wpcd_fixed_toolbar',
3881
- paste_as_text: true,
3882
- toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',
3883
- setup: function setup(ed) {
3884
- ed.on('change', function (e) {
3885
- var row = WPTB_Helper.findAncestor(node, 'wptb-row');
3886
- if (row.classList.contains('wptb-table-head')) {
3887
- var table = WPTB_Helper.findAncestor(row, 'wptb-preview-table');
3888
- WPTB_Helper.dataTitleColumnSet(table);
3889
- }
3890
- });
3891
- },
3892
- init_instance_callback: function init_instance_callback(editor) {
3893
- window.currentEditor = editor;
3894
- //editor.fire('focus');
3895
- editor.on('focus', function (e) {
3896
- var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;
3897
- if (window.currentEditor && document.getElementById('wptb_builder').scrollTop >= 55 && window.currentEditor.bodyElement.style.display != 'none') {
3898
- document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';
3899
- document.getElementById('wpcd_fixed_toolbar').style.right = totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2 + 'px';
3900
- document.getElementById('wpcd_fixed_toolbar').style.top = '100px';
3901
- } else {
3902
- document.getElementById('wpcd_fixed_toolbar').style.position = 'static';
3903
- delete document.getElementById('wpcd_fixed_toolbar').style.right;
3904
- delete document.getElementById('wpcd_fixed_toolbar').style.top;
3905
- }
3906
- });
3907
- }
3908
- });
3909
- } else {
3910
- listItems = node.getElementsByClassName('wptb-list-item-content');
3911
- for (var _i = 0; _i < listItems.length; _i++) {
3912
- WPTB_Helper.listItemsTinyMceInit(listItems[_i]);
3913
- }
3914
- }
3915
-
3916
- actions.appendChild(btnMove);
3917
- actions.appendChild(btnCopy);
3918
- actions.appendChild(btnDelete);
3919
- this.appendChild(actions);
3920
- };
3921
-
3922
- node.onmouseleave = function (event) {
3923
- this.classList.remove('wptb-directlyhovered');
3924
- var iter = 0;
3925
- while (event.target.querySelector('.wptb-actions') && iter < 5) {
3926
- event.target.querySelector('.wptb-actions').remove();
3927
- iter++;
3928
- }
3929
- };
3930
-
3931
- // Change data-title-column if the title was changed
3932
- if (element.kind == 'text') {
3933
- var observer = new MutationObserver(function (mutations) {
3934
- var row = WPTB_Helper.findAncestor(node, 'wptb-row');
3935
- if (row.classList.contains('wptb-table-head')) {
3936
- var table = WPTB_Helper.findAncestor(row, 'wptb-preview-table');
3937
- WPTB_Helper.dataTitleColumnSet(table);
3938
- }
3939
- });
3940
- var config = { attributes: true, attributeFilter: ['style'] };
3941
- observer.observe(element.getDOMElement(), config);
3942
- }
3943
-
3944
- var node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\d+)/i);
3945
- if (node_wptb_element_kind_num) {
3946
- node.classList.remove(node_wptb_element_kind_num[0]);
3947
- }
3948
- if (!node.classList.contains('wptb-ph-element')) {
3949
- node.classList.add('wptb-ph-element');
3950
- if (!node.classList.contains('wptb-element-' + element.kind + '-' + index)) {
3951
- node.classList.add('wptb-element-' + element.kind + '-' + index);
3952
- }
3953
- } else {
3954
- if (!node.classList.contains('wptb-element-' + element.kind + '-' + index)) {
3955
- node.classList.add('wptb-element-' + element.kind + '-' + index);
3956
- }
3957
- }
3958
- new WPTB_ElementOptions(element, index, kindIndexProt);
3959
-
3960
- document.counter.increment(element.kind);
3961
- };
3962
-
3963
  //# sourceMappingURL=admin.js.map
1
+ var applyGenericItemSettings = function applyGenericItemSettings(element, kindIndexProt) {
2
+ var copy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3
+
4
+ var node = element.getDOMElement(),
5
+ index,
6
+ listItems,
7
+ copy;
8
+
9
+ if (kindIndexProt == undefined || copy == true) {
10
+ index = document.counter.nextIndex(element.kind);
11
+ var wptbElements = document.getElementsByClassName('wptb-ph-element');
12
+ var elementIndexesArr = [];
13
+ for (var i = 0; i < wptbElements.length; i++) {
14
+ var regex = new RegExp('wptb-element-' + element.kind + '-(\\d+)', "i");
15
+ var infArr = wptbElements[i].className.match(regex);
16
+ if (infArr) {
17
+ elementIndexesArr.push(infArr[1]);
18
+ }
19
+ }
20
+ if (elementIndexesArr.length > 0) {
21
+ var elementIndexMax = Math.max.apply(Math, elementIndexesArr);
22
+ index = elementIndexMax + 1;
23
+ } else {
24
+ index = 1;
25
+ }
26
+ } else if (kindIndexProt && !copy) {
27
+ index = kindIndexProt.split('-')[1];
28
+ }
29
+
30
+ node.onmouseenter = function (event) {
31
+ this.classList.add('wptb-directlyhovered');
32
+ var btnDelete = document.createElement('span'),
33
+ btnCopy = document.createElement('span'),
34
+ btnMove = document.createElement('span'),
35
+ actions = document.createElement('span'),
36
+ i = void 0;
37
+
38
+ actions.classList.add('wptb-actions');
39
+ btnDelete.classList.add('dashicons', 'dashicons-trash', 'wptb-delete-action');
40
+ btnCopy.classList.add('dashicons', 'dashicons-admin-page', 'wptb-duplicate-action');
41
+ btnMove.classList.add("dashicons", "dashicons-move", 'wptb-move-action');
42
+ btnMove.draggable = true;
43
+ btnDelete.onclick = function (event) {
44
+ var act = this.parentNode.parentNode,
45
+ el = act.parentNode;
46
+ el.removeChild(act);
47
+
48
+ if (act.kind == 'text') {
49
+ var thisRow = el.parentNode;
50
+ if (thisRow.classList.contains('wptb-table-head')) {
51
+ var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
52
+ WPTB_Helper.dataTitleColumnSet(table);
53
+ }
54
+ }
55
+ };
56
+ btnCopy.onclick = function (event) {
57
+ var copy = void 0;
58
+ if (element.kind == 'list') {
59
+ var td = event.target.parentNode.parentNode.parentNode,
60
+ temp = [],
61
+ srcList = event.target.parentNode.parentNode.querySelectorAll('ul li .wptb-list-item-content');
62
+
63
+ for (var i = 0; i < srcList.length; i++) {
64
+ temp.push(srcList[i].innerHTML);
65
+ }
66
+
67
+ copy = new WPTB_List(temp, node);
68
+
69
+ node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
70
+ } else if (element.kind == 'text') {
71
+ var td = event.target.parentNode.parentNode.parentNode;
72
+ copy = new WPTB_Text(event.target.parentNode.parentNode.childNodes[0].innerHTML, node);
73
+
74
+ node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
75
+ } else if (element.kind == 'image') {
76
+ var td = event.target.parentNode.parentNode.parentNode;
77
+ copy = new WPTB_Image(event.target.parentNode.parentNode.children[0].children[0].src, node);
78
+
79
+ node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
80
+ } else {
81
+ var td = event.target.parentNode.parentNode.parentNode,
82
+ text = event.target.parentNode.parentNode.childNodes[0].querySelector('p').innerHTML;
83
+ copy = new WPTB_Button(text, node);
84
+
85
+ node.parentNode.insertBefore(copy.getDOMElement(), node.nextSibling);
86
+ }
87
+
88
+ WPTB_innerElementSet(copy.getDOMElement());
89
+ };
90
+ var parent = this,
91
+ infArr = void 0,
92
+ type = void 0;
93
+ infArr = parent.className.match(/wptb-element-(.+)-(\d+)/i);
94
+ type = infArr[1];
95
+ var dragImagesArr = WPTB_Helper.dragImagesArr();
96
+ btnMove.ondragstart = function (event) {
97
+ this.parentNode.style.opacity = 0;
98
+ parent.classList.remove('wptb-directlyhovered');
99
+ parent.classList.add('wptb-moving-mode');
100
+
101
+ event.dataTransfer.setDragImage(dragImagesArr[type], 0, 0);
102
+ event.dataTransfer.setData('node', 'wptb-element-' + infArr[1] + '-' + infArr[2]);
103
+ event.dataTransfer.setData('wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2]);
104
+ event.dataTransfer.setData('wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1]);
105
+ var act = event.target.parentNode.parentNode;
106
+ if (act.kind == 'text') {
107
+ var thisRow = el.parentNode;
108
+ if (thisRow.classList.contains('wptb-table-head')) {
109
+ var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
110
+ WPTB_Helper.dataTitleColumnSet(table);
111
+ }
112
+ }
113
+ };
114
+
115
+ if (element.kind === 'button') {
116
+ var a = node.querySelector('a'),
117
+ target = a.querySelector('div');
118
+ a.onclick = function (e) {
119
+ e.preventDefault();
120
+ };
121
+ WPTB_Helper.buttonsTinyMceInit(target);
122
+ } else if (element.kind === 'text') {
123
+ tinyMCE.init({
124
+ target: node.childNodes[0],
125
+ inline: true,
126
+ plugins: "link, paste",
127
+ dialog_type: "modal",
128
+ theme: 'modern',
129
+ menubar: false,
130
+ fixed_toolbar_container: '#wpcd_fixed_toolbar',
131
+ paste_as_text: true,
132
+ toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',
133
+ setup: function setup(ed) {
134
+ ed.on('change', function (e) {
135
+ var row = WPTB_Helper.findAncestor(node, 'wptb-row');
136
+ if (row.classList.contains('wptb-table-head')) {
137
+ var table = WPTB_Helper.findAncestor(row, 'wptb-preview-table');
138
+ WPTB_Helper.dataTitleColumnSet(table);
139
+ }
140
+ });
141
+ },
142
+ init_instance_callback: function init_instance_callback(editor) {
143
+ window.currentEditor = editor;
144
+ //editor.fire('focus');
145
+ editor.on('focus', function (e) {
146
+ var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;
147
+ if (window.currentEditor && document.getElementById('wptb_builder').scrollTop >= 55 && window.currentEditor.bodyElement.style.display != 'none') {
148
+ document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';
149
+ document.getElementById('wpcd_fixed_toolbar').style.right = totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2 + 'px';
150
+ document.getElementById('wpcd_fixed_toolbar').style.top = '100px';
151
+ } else {
152
+ document.getElementById('wpcd_fixed_toolbar').style.position = 'static';
153
+ delete document.getElementById('wpcd_fixed_toolbar').style.right;
154
+ delete document.getElementById('wpcd_fixed_toolbar').style.top;
155
+ }
156
+ });
157
+ }
158
+ });
159
+ } else {
160
+ listItems = node.getElementsByClassName('wptb-list-item-content');
161
+ for (var _i = 0; _i < listItems.length; _i++) {
162
+ WPTB_Helper.listItemsTinyMceInit(listItems[_i]);
163
+ }
164
+ }
165
+
166
+ actions.appendChild(btnMove);
167
+ actions.appendChild(btnCopy);
168
+ actions.appendChild(btnDelete);
169
+ this.appendChild(actions);
170
+ };
171
+
172
+ node.onmouseleave = function (event) {
173
+ this.classList.remove('wptb-directlyhovered');
174
+ var iter = 0;
175
+ while (event.target.querySelector('.wptb-actions') && iter < 5) {
176
+ event.target.querySelector('.wptb-actions').remove();
177
+ iter++;
178
+ }
179
+ };
180
+
181
+ // Change data-title-column if the title was changed
182
+ if (element.kind == 'text') {
183
+ var observer = new MutationObserver(function (mutations) {
184
+ var row = WPTB_Helper.findAncestor(node, 'wptb-row');
185
+ if (row.classList.contains('wptb-table-head')) {
186
+ var table = WPTB_Helper.findAncestor(row, 'wptb-preview-table');
187
+ WPTB_Helper.dataTitleColumnSet(table);
188
+ }
189
+ });
190
+ var config = { attributes: true, attributeFilter: ['style'] };
191
+ observer.observe(element.getDOMElement(), config);
192
+ }
193
+
194
+ var node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\d+)/i);
195
+ if (node_wptb_element_kind_num) {
196
+ node.classList.remove(node_wptb_element_kind_num[0]);
197
+ }
198
+ if (!node.classList.contains('wptb-ph-element')) {
199
+ node.classList.add('wptb-ph-element');
200
+ if (!node.classList.contains('wptb-element-' + element.kind + '-' + index)) {
201
+ node.classList.add('wptb-element-' + element.kind + '-' + index);
202
+ }
203
+ } else {
204
+ if (!node.classList.contains('wptb-element-' + element.kind + '-' + index)) {
205
+ node.classList.add('wptb-element-' + element.kind + '-' + index);
206
+ }
207
+ }
208
+ new WPTB_ElementOptions(element, index, kindIndexProt);
209
+
210
+ document.counter.increment(element.kind);
211
+ };
212
+
213
  (function () {
214
  var WPTB_Builder = function WPTB_Builder() {
215
  var table_id = WPTB_Helper.detectMode();
442
  getDOMElement().appendChild(node);
443
  };
444
 
445
+ DOMElement.getCellDimensions = function () {
446
+ var tdStyleObj = window.getComputedStyle(this, null);
447
+
448
+ var tdPaddingLeft = tdStyleObj.getPropertyValue('padding-left');
449
+ var tdPaddingRight = tdStyleObj.getPropertyValue('padding-right');
450
+
451
+ var tdBorderLeftWidth = tdStyleObj.getPropertyValue('border-left-width');
452
+ var tdBorderRightWidth = tdStyleObj.getPropertyValue('border-right-width');
453
+
454
+ var tdPaddingTop = tdStyleObj.getPropertyValue('padding-top');
455
+ var tdPaddingBottom = tdStyleObj.getPropertyValue('padding-bottom');
456
+
457
+ var tdBorderTopWidth = tdStyleObj.getPropertyValue('border-top-width');
458
+ var tdBorderBottomWidth = tdStyleObj.getPropertyValue('border-bottom-width');
459
+
460
+ var width = parseFloat(this.offsetWidth, 10) - parseFloat(tdPaddingLeft, 10) - parseFloat(tdPaddingRight, 10) - parseFloat(tdBorderLeftWidth, 10) - parseFloat(tdBorderRightWidth, 10);
461
+
462
+ var height = parseFloat(this.offsetHeight, 10) - parseFloat(tdPaddingTop, 10) - parseFloat(tdPaddingBottom, 10) - parseFloat(tdBorderTopWidth, 10) - parseFloat(tdBorderBottomWidth, 10);
463
+
464
+ return {
465
+ width: width,
466
+ height: height
467
+ };
468
+ };
469
+
470
  return this;
471
  };
472
  var WPTB_DropHandle = function WPTB_DropHandle(thisElem, e) {
1371
  for (var j = 0; j < tdElements.length; j++) {
1372
  var element = tdElements[j];
1373
  if (element.classList.contains('wptb-ph-element')) {
 
1374
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i);
1375
  if (infArr[1] == 'text') {
1376
  var p = element.querySelector('p'),
1455
  if (!results) return false;
1456
  if (!results[2]) return '';
1457
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
1458
+ },
1459
+ getColumnWidth: function getColumnWidth(table, cell) {
1460
+ var xIndex = cell.dataset.xIndex;
1461
+ var xIndexes = table.querySelectorAll('[data-x-index="' + xIndex + '"]');
1462
+ var cellWidth = cell.getCellDimensions().width;
1463
+ for (var i = 0; i < xIndexes.length; i++) {
1464
+ if (cellWidth > xIndexes[i].getCellDimensions().width) {
1465
+ cellWidth = xIndexes[i].getCellDimensions().width;
1466
+ }
1467
+ }
1468
+ return cellWidth;
1469
+ },
1470
+ getRowHeight: function getRowHeight(table, cell) {
1471
+ var yIndex = cell.dataset.yIndex;
1472
+ var yIndexes = table.querySelectorAll('[data-y-index="' + yIndex + '"]');
1473
+ var cellHeight = cell.getCellDimensions().height;
1474
+ for (var i = 0; i < yIndexes.length; i++) {
1475
+ if (cellHeight > yIndexes[i].getCellDimensions().height) {
1476
+ cellHeight = yIndexes[i].getCellDimensions().height;
1477
+ }
1478
+ }
1479
+ return cellHeight;
1480
  }
1481
  };
1482
  var WPTB_Image = function WPTB_Image(src, DOMElementProt) {
1580
  // WPTB_LeftPanel();
1581
  // }
1582
  };
1583
+ var WPTB_innerElementSet = function WPTB_innerElementSet(element) {
 
 
 
1584
 
1585
+ function newElementProxy(el) {
1586
+ if (el == 'list') {
1587
+ return new WPTB_List();
1588
+ } else if (el == 'image') {
1589
+ return new WPTB_Image();
1590
+ } else if (el == 'text') {
1591
+ return new WPTB_Text();
1592
+ } else if (el == 'button') {
1593
+ return new WPTB_Button();
 
 
1594
  }
1595
  }
1596
 
1597
+ element.ondragenter = function (e) {
1598
+ var div;
1599
+ if (e.dataTransfer.types.indexOf('wptbelement') == -1 && e.dataTransfer.types.indexOf('wptb-moving-mode') == -1) {
1600
+ return;
1601
+ }
1602
+ WPTB_DropHandle(this, e);
1603
+
1604
+ element.classList.add('wptb-ondragenter');
1605
+ };
1606
+ element.ondragover = function (e) {
1607
+ e.preventDefault();
1608
+ WPTB_DropHandle(this, e);
1609
+ };
1610
+ element.ondragleave = function () {};
1611
+ element.ondrop = function (e) {
1612
+ this.classList.remove('wptb-ondragenter');
1613
+ var element = void 0,
1614
+ classId = void 0;
1615
+ e.preventDefault();
1616
+ e.stopPropagation();
1617
+
1618
+ if (!e.dataTransfer.getData('wptbElement') && !e.dataTransfer.getData('node')) {
1619
+ return;
1620
+ }
1621
+ var wptbDropHandle = void 0,
1622
+ wptbDropBorderMarker = void 0;
1623
+ if (document.getElementsByClassName('wptb-drop-handle').length > 0) {
1624
+ wptbDropHandle = document.getElementsByClassName('wptb-drop-handle')[0];
1625
+ }
1626
+ if (document.getElementsByClassName('wptb-drop-border-marker').length > 0) {
1627
+ wptbDropBorderMarker = document.getElementsByClassName('wptb-drop-border-marker')[0];
1628
+ }
1629
+
1630
+ if (e.dataTransfer.getData('wptbElement')) {
1631
+ element = newElementProxy(e.dataTransfer.getData('wptbElement'));
1632
+ element = element.getDOMElement();
1633
+ } else {
1634
+ classId = e.dataTransfer.getData('node');
1635
+ element = document.getElementsByClassName(classId)[0];
1636
+ element.classList.remove('wptb-moving-mode');
1637
+ }
1638
+
1639
+ if (wptbDropHandle.style.display == 'block') {
1640
+ var td = void 0;
1641
+ if (wptbDropHandle.dataset.text == 'Drop Here') {
1642
+ td = wptbDropHandle.getDOMParentElement();
1643
+ td.appendChild(element);
1644
+ } else {
1645
+ var innerElement = wptbDropHandle.getDOMParentElement();
1646
+ td = innerElement.parentNode;
1647
+
1648
+ if (wptbDropHandle.dataset.text == 'Abowe Element') {
1649
+ td.insertBefore(element, innerElement);
1650
+ } else if (wptbDropHandle.dataset.text == 'Below Element') {
1651
+ var innerElementNext = innerElement.nextSibling;
1652
+ td.insertBefore(element, innerElementNext);
1653
+ }
1654
+ }
1655
+ var thisRow = td.parentNode;
1656
+ if (thisRow.classList.contains('wptb-table-head')) {
1657
+ var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
1658
+ WPTB_Helper.dataTitleColumnSet(table);
1659
+ }
1660
+ } else {
1661
+ return;
1662
+ }
1663
+
1664
+ wptbDropHandle.style.display = 'none';
1665
+ wptbDropBorderMarker.style.display = 'none';
1666
+
1667
+ WPTB_innerElementSet(element);
1668
+
1669
+ return true;
1670
+ };
1671
+ element.onmouseover = function (e) {
1672
+ element.classList.remove('wptb-ondragenter');
1673
+ };
1674
+ };
1675
+ var WPTB_LeftPanel = function WPTB_LeftPanel() {
1676
+
1677
+ var table = document.getElementsByClassName('wptb-preview-table')[0],
1678
+ wptbElementButtons = document.getElementsByClassName('wptb-element');
1679
+
1680
+ function wptbTdBgColorSavedSet(inputId, trNumber) {
1681
+ if (trNumber > 3) return;
1682
+ if (table) {
1683
+ var tableRows = table.getElementsByTagName('tr');
1684
+ if (tableRows.length > trNumber) {
1685
+ var trBackgroundColor = tableRows[trNumber].style.backgroundColor;
1686
+ var wptbEvenRowBg = document.getElementById(inputId);
1687
+ if (wptbEvenRowBg && trBackgroundColor) {
1688
+ wptbEvenRowBg.value = WPTB_Helper.rgbToHex(trBackgroundColor);
1689
+ }
1690
+ }
1691
+ }
1692
+ }
1693
+
1694
+ wptbTdBgColorSavedSet('wptb-even-row-bg', 1);
1695
+ jQuery('#wptb-even-row-bg').wpColorPicker({
1696
  change: function change(event, ui) {
1697
  var tableRows = table.getElementsByTagName('tr');
1698
  for (var _i = 1; _i < tableRows.length; _i += 2) {
1872
  var tableCells = wptbPreviewTable[0].getElementsByTagName('td');
1873
  for (var i = 0; i < tableCells.length; i++) {
1874
  tableCells[i].style.border = '0px solid ' + color;
1875
+ tableCells[i].style.border = null;
1876
  }
1877
  }
1878
  }
1944
  var wptbImageWidthNumber = document.getElementById('wptb-image-width-number');
1945
  numberImputSize(wptbImageWidthNumber, 2, 100);
1946
 
1947
+ var wptbTableColumnWidthNumber = document.getElementById('wptb-table-column-width-number');
1948
+ numberImputSize(wptbTableColumnWidthNumber, 2, 500);
1949
+
1950
+ var wptbTableRowHeightNumber = document.getElementById('wptb-table-row-height-number');
1951
+ numberImputSize(wptbTableRowHeightNumber, 2, 200);
1952
+
1953
  document.getElementById('wptb-table-cell-slider').oninput = function () {
1954
  document.getElementById('wptb-table-cell-number').value = this.value;
1955
  addCellPadding(this.value);
1956
+ table.tdDefaultWidth();
1957
  };
1958
 
1959
  document.getElementById('wptb-table-cell-number').onchange = function () {
1960
  document.getElementById('wptb-table-cell-slider').value = this.value;
1961
  addCellPadding(this.value);
1962
+ table.tdDefaultWidth();
1963
  };
1964
 
1965
  document.getElementById('wptb-table-border-slider').oninput = function () {
1966
  document.getElementById('wptb-table-border-number').value = this.value;
1967
  addBorderSize(this.value);
1968
+ table.tdDefaultWidth();
1969
 
1970
  var wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,
1971
  tableBorderColorSetArea = document.getElementById('wptb-table-border-color-set-area');
1979
  document.getElementById('wptb-table-border-number').onchange = function () {
1980
  document.getElementById('wptb-table-border-slider').value = this.value;
1981
  addBorderSize(this.value);
1982
+ table.tdDefaultWidth();
1983
  };
1984
 
1985
  document.getElementById('wptb-table-inner-border-slider').oninput = function () {
1986
  document.getElementById('wptb-table-inner-border-number').value = this.value;
1987
  addInnerBorderSize(this.value);
1988
+ table.tdDefaultWidth();
1989
  };
1990
 
1991
  document.getElementById('wptb-table-inner-border-number').onchange = function () {
1992
  document.getElementById('wptb-table-inner-border-slider').value = this.value;
1993
  addInnerBorderSize(this.value);
1994
+ table.tdDefaultWidth();
1995
  };
1996
 
1997
  document.getElementById('wptb-inner-border-check').onchange = function () {
2008
  }
2009
  };
2010
 
2011
+ document.getElementById('wptb-table-column-width-slider').oninput = function () {
2012
+ document.getElementById('wptb-table-column-width-number').value = this.value;
2013
+ table.addColumnWidth(this.value);
2014
+ };
2015
+
2016
+ document.getElementById('wptb-table-column-width-number').onchange = function () {
2017
+ document.getElementById('wptb-table-column-width-slider').value = this.value;
2018
+ table.addColumnWidth(this.value);
2019
+ };
2020
+
2021
+ document.getElementById('wptb-table-column-width-auto-fixed').onchange = function () {
2022
+ if (this.checked) {
2023
+ var highlighted = table.querySelector('.wptb-highlighted');
2024
+ var width = WPTB_Helper.getColumnWidth(table, highlighted);
2025
+ table.addColumnWidth(width);
2026
+ } else {
2027
+ table.addColumnWidth(false, true);
2028
+ var _highlighted = table.querySelector('.wptb-highlighted');
2029
+ var _width = WPTB_Helper.getColumnWidth(table, _highlighted);
2030
+ document.getElementById('wptb-table-column-width-number').value = _width;
2031
+ document.getElementById('wptb-table-column-width-slider').value = _width;
2032
+ }
2033
+ };
2034
+
2035
+ document.getElementById('wptb-table-row-height-slider').oninput = function () {
2036
+ document.getElementById('wptb-table-row-height-number').value = this.value;
2037
+ table.addRowHeight(this.value);
2038
+ };
2039
+
2040
+ document.getElementById('wptb-table-row-height-number').onchange = function () {
2041
+ document.getElementById('wptb-table-row-height-slider').value = this.value;
2042
+ table.addRowHeight(this.value);
2043
+ };
2044
+
2045
+ document.getElementById('wptb-table-row-height-auto-fixed').onchange = function () {
2046
+ if (this.checked) {
2047
+ var highlighted = table.querySelector('.wptb-highlighted');
2048
+ var height = WPTB_Helper.getRowHeight(table, highlighted);
2049
+ table.addRowHeight(height);
2050
+ } else {
2051
+ table.addRowHeight(false, true);
2052
+ var _highlighted2 = table.querySelector('.wptb-highlighted');
2053
+ var _height = WPTB_Helper.getRowHeight(table, _highlighted2);
2054
+ document.getElementById('wptb-table-row-height-number').value = _height;
2055
+ document.getElementById('wptb-table-row-height-slider').value = _height;
2056
+ }
2057
+ };
2058
+
2059
  function createMobileHeadForTable(table, thisEvent) {
2060
 
2061
  if (thisEvent.checked) {
2592
  var code = codeMain.cloneNode(true);
2593
  code.classList.add('wptb-table-preview-static-indic');
2594
  code.dataset.tableColumns = codeMain.columns;
2595
+ code.style.width = null;
2596
+ code.style.minWidth = null;
2597
+ code.style.maxWidth = null;
2598
 
2599
  var tds = code.getElementsByTagName('td');
2600
  if (tds.length > 0) {
2601
  for (var i = 0; i < tds.length; i++) {
2602
 
 
 
 
 
 
 
 
2603
  if (codeMain.querySelector('wptb-table-preview-head')) {
2604
  tds[i].removeAttribute('data-x-index');
2605
  }
2759
  noCells = document.getElementsByClassName('wptb-no-cell-action'),
2760
  singleCells = document.getElementsByClassName('wptb-single-action'),
2761
  multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),
2762
+ cellSettings = document.getElementById('wptb-left-scroll-panel-cell-settings'),
2763
  position = getCoords(this),
2764
  row = position[0],
2765
  column = position[1];
2796
  singleCells[i].classList.remove('visible');
2797
  singleCells[i].setAttribute('disabled', 'disabled');
2798
  }
2799
+ cellSettings.classList.remove('visible');
2800
  } else if (markedCells === 1) {
2801
  for (var i = 0; i < multipleCells.length; i++) {
2802
  multipleCells[i].classList.remove('visible');
2810
  singleCells[i].classList.add('visible');
2811
  singleCells[i].removeAttribute('disabled');
2812
  }
2813
+ var cellHighlighted = document.querySelector('.wptb-highlighted');
2814
+ if (cellHighlighted) {
2815
+ var wptbTableColumnWidthSlider = document.getElementById('wptb-table-column-width-slider');
2816
+ var wptbTableColumnWidthNumber = document.getElementById('wptb-table-column-width-number');
2817
+ var tableColumnWidthAutoFixedCheckbox = document.getElementById('wptb-table-column-width-auto-fixed');
2818
+ var width = cellHighlighted.style.width;
2819
+ if (width) {
2820
+ wptbTableColumnWidthSlider.value = parseFloat(width, 10);
2821
+ wptbTableColumnWidthNumber.value = parseFloat(width, 10);
2822
+ tableColumnWidthAutoFixedCheckbox.checked = true;
2823
+ } else if (cellHighlighted.dataset.wptbFixedWidth) {
2824
+ wptbTableColumnWidthSlider.value = cellHighlighted.dataset.wptbFixedWidth;
2825
+ wptbTableColumnWidthNumber.value = cellHighlighted.dataset.wptbFixedWidth;
2826
+ tableColumnWidthAutoFixedCheckbox.checked = true;
2827
+ } else {
2828
+ var cellWidth = WPTB_Helper.getColumnWidth(table, cellHighlighted);
2829
+ wptbTableColumnWidthSlider.value = cellWidth;
2830
+ wptbTableColumnWidthNumber.value = cellWidth;
2831
+ tableColumnWidthAutoFixedCheckbox.checked = false;
2832
+ }
2833
+
2834
+ var wptbTableRowHeightSlider = document.getElementById('wptb-table-row-height-slider');
2835
+ var wptbTableRowHeightNumber = document.getElementById('wptb-table-row-height-number');
2836
+ var tableRowHeightAutoFixedCheckbox = document.getElementById('wptb-table-row-height-auto-fixed');
2837
+ var height = cellHighlighted.style.height;
2838
+ if (height) {
2839
+ wptbTableRowHeightSlider.value = parseFloat(height, 10);
2840
+ wptbTableRowHeightNumber.value = parseFloat(height, 10);
2841
+ tableRowHeightAutoFixedCheckbox.checked = true;
2842
+ } else if (cellHighlighted.dataset.wptbFixedHeight) {
2843
+ wptbTableRowHeightSlider.value = cellHighlighted.dataset.wptbFixedHeight;
2844
+ wptbTableRowHeightNumber.value = cellHighlighted.dataset.wptbFixedHeight;
2845
+ tableRowHeightAutoFixedCheckbox.checked = true;
2846
+ } else {
2847
+ var cellHeight = WPTB_Helper.getRowHeight(table, cellHighlighted);
2848
+ wptbTableRowHeightSlider.value = cellHeight;
2849
+ wptbTableRowHeightNumber.value = cellHeight;
2850
+ tableRowHeightAutoFixedCheckbox.checked = false;
2851
+ }
2852
+ }
2853
+ cellSettings.classList.add('visible');
2854
  } else {
2855
  for (var i = 0; i < multipleCells.length; i++) {
2856
  if (table.isSquare(array)) {
2869
  singleCells[i].classList.remove('visible');
2870
  singleCells[i].setAttribute('disabled', 'disabled');
2871
  }
2872
+ cellSettings.classList.remove('visible');
2873
  }
2874
  };
2875
 
3127
 
3128
  //Create a HTML Table element.
3129
  table = document.createElement('table');
3130
+ table.classList.add('wptb-preview-table', 'wptb-preview-table-default-width');
3131
+ table.dataset.reconstraction = 1;
3132
  //Add the data rows.
3133
  for (var i = 0; i < rows; i++) {
3134
 
3166
  var bar = document.getElementsByClassName('wptb-edit-bar'),
3167
  cellModeBackground = document.getElementById('wptb-cell_mode_background'),
3168
  leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
3169
+ leftScrollPanelCellSettings = document.getElementById('wptb-left-scroll-panel-cell-settings'),
3170
  wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
3171
  if (wptbPreviewTable.length > 0) {
3172
  wptbPreviewTable = wptbPreviewTable[0];
3179
  bar[_i2].classList.remove('visible');
3180
  cellModeBackground.classList.remove('visible');
3181
  leftScrollPanelCurtain.classList.remove('visible');
3182
+ leftScrollPanelCellSettings.classList.remove('visible');
3183
  wptbPreviewTable.classList.remove('wptb-preview-table-manage-cells');
3184
  var wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');
3185
  if (wptbPreviewTableTds.length > 0) {
3207
  var trs = this.getElementsByTagName('tr'),
3208
  tds = void 0,
3209
  maxCols = 0,
3210
+ maxColsFull = 0,
3211
  tdsArr = [];
3212
  var wptbTopRowAsHeader = document.getElementById('wptb-top-row-as-header');
3213
 
3284
  }
3285
  }
3286
  jMainIter++;
3287
+ if (i == 0) {
3288
+ maxColsFull = jMainIter;
3289
+ }
3290
  }
3291
  if (j > maxCols) {
3292
  maxCols = j;
3293
  }
3294
  }
3295
  this.columns = maxCols;
3296
+ this.maxCols = maxColsFull;
3297
+ };
3298
+
3299
+ table.addColumnWidth = function (value, cleaner) {
3300
+ var highlighted = table.getElementsByClassName('wptb-highlighted');
3301
+ if (highlighted.length > 0) {
3302
+ for (var _k3 = 0; _k3 < highlighted.length; _k3++) {
3303
+ var dataXIndex = highlighted[_k3].dataset.xIndex;
3304
+ if (dataXIndex) {
3305
+ (function () {
3306
+ var tableTdsFor = function tableTdsFor(dataXIndex, colspan) {
3307
+ var tableRows = table.rows;
3308
+ var widthIsSet = false;
3309
+ var arrayTdsFromPreviousRow = [];
3310
+ for (var _i4 = 0; _i4 < tableRows.length; _i4++) {
3311
+ var _row = tableRows[_i4];
3312
+ var tds = _row.children;
3313
+ for (var _j = 0; _j < tds.length; _j++) {
3314
+ var td = tds[_j];
3315
+ if (td.dataset.xIndex == dataXIndex) {
3316
+ if (value) {
3317
+ if (td.colSpan == colspan) {
3318
+ td.style.width = value + 'px';
3319
+ td.removeAttribute('data-wptb-fixed-width');
3320
+ widthIsSet = true;
3321
+ var tableColumnWidthAutoFixedCheckbox = document.getElementById('wptb-table-column-width-auto-fixed');
3322
+ if (!tableColumnWidthAutoFixedCheckbox.checked) {
3323
+ tableColumnWidthAutoFixedCheckbox.checked = true;
3324
+ }
3325
+ } else {
3326
+ td.style.width = null;
3327
+ td.dataset.wptbFixedWidth = value;
3328
+ if (_i4 == tableRows.length - 1 && !widthIsSet) {
3329
+ tableTdsFor(dataXIndex, colspan + 1);
3330
+ }
3331
+ }
3332
+ } else if (cleaner) {
3333
+ td.style.width = null;
3334
+ td.removeAttribute('data-wptb-fixed-width');
3335
+ } else {
3336
+ if (td.dataset.wptbFixedWidth) {
3337
+ if (td.colSpan == colspan) {
3338
+ td.style.width = td.dataset.wptbFixedWidth + 'px';
3339
+ td.removeAttribute('data-wptb-fixed-width');
3340
+ }
3341
+ } else if (td.style.width) {
3342
+ for (var z = 0; z < arrayTdsFromPreviousRow.length; z++) {
3343
+ arrayTdsFromPreviousRow[z].style.width = td.style.width;
3344
+ }
3345
+ arrayTdsFromPreviousRow = [];
3346
+ } else {
3347
+ arrayTdsFromPreviousRow.push(td);
3348
+ }
3349
+ }
3350
+ break;
3351
+ }
3352
+ }
3353
+ }
3354
+ };
3355
+
3356
+ tableTdsFor(dataXIndex, 1);
3357
+ })();
3358
+ }
3359
+ }
3360
+
3361
+ table.tdDefaultWidth();
3362
+ }
3363
+ };
3364
+
3365
+ table.tdDefaultWidth = function () {
3366
+ var rows = table.rows;
3367
+
3368
+ var tableTdsSumMaxWidth = 0;
3369
+ var tableTdsSumMaxWidthFixed = 0;
3370
+ var tableTdsSumMaxWidthAuto = 0;
3371
+
3372
+ var wptbTableSetup = document.getElementsByClassName('wptb-table-setup')[0];
3373
+ var wptbTableSetupWidth = wptbTableSetup.offsetWidth;
3374
+
3375
+ var arrayCellsWidthFixedHelper = [];
3376
+ var arrayCellsWidthAutoHelper = [];
3377
+ var tdPaddingCommon = 0;
3378
+ var tableTdBorderCommonWidth = 0;
3379
+ var cssForTdsWidthAuto = '';
3380
+
3381
+ for (var _i5 = 0; _i5 < rows.length; _i5++) {
3382
+ var tds = rows[_i5].children;
3383
+ for (var _j2 = 0; _j2 < tds.length; _j2++) {
3384
+ var td = tds[_j2];
3385
+
3386
+ if (!arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] && !arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)]) {
3387
+ if (td.style.width) {
3388
+ arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] = parseFloat(td.style.width);
3389
+ td.removeAttribute('data-wptb-css-td-auto-width');
3390
+ } else {
3391
+ if (!td.dataset.wptbFixedWidth) {
3392
+ arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] = 100;
3393
+ td.dataset.wptbCssTdAutoWidth = true;
3394
+ }
3395
+ }
3396
+
3397
+ if (window.getComputedStyle(td, null)) {
3398
+ var tdStyleObj = window.getComputedStyle(td, null);
3399
+ var tdPaddingLeft = tdStyleObj.getPropertyValue('padding-left');
3400
+ var tdPaddingRight = tdStyleObj.getPropertyValue('padding-right');
3401
+ tdPaddingCommon = parseFloat(tdPaddingLeft, 10) + parseFloat(tdPaddingRight, 10);
3402
+
3403
+ var tableTdBorderLeftWidth = tdStyleObj.getPropertyValue('border-left-width');
3404
+ var tableTdBorderRightWidth = tdStyleObj.getPropertyValue('border-right-width');
3405
+ tableTdBorderCommonWidth = parseFloat(tableTdBorderLeftWidth, 10) + parseFloat(tableTdBorderRightWidth, 10);
3406
+ if (arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)]) {
3407
+ arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] += tdPaddingCommon;
3408
+ arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] += tableTdBorderCommonWidth;
3409
+ } else {
3410
+ arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] += tdPaddingCommon;
3411
+ arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] += tableTdBorderCommonWidth;
3412
+ }
3413
+ }
3414
+ } else if (arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)]) {
3415
+ if (!td.dataset.wptbFixedWidth) {
3416
+ td.dataset.wptbCssTdAutoWidth = true;
3417
+ }
3418
+ } else if (arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)]) {
3419
+ td.removeAttribute('data-wptb-css-td-auto-width');
3420
+ }
3421
+ }
3422
+ }
3423
+
3424
+ for (var _i6 = 0; _i6 < arrayCellsWidthFixedHelper.length; _i6++) {
3425
+ if (arrayCellsWidthFixedHelper[_i6]) {
3426
+ tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[_i6];
3427
+ }
3428
+ }
3429
+
3430
+ var CellsWidthAutoCount = 0;
3431
+ for (var _i7 = 0; _i7 < arrayCellsWidthAutoHelper.length; _i7++) {
3432
+ if (arrayCellsWidthAutoHelper[_i7]) {
3433
+ tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[_i7];
3434
+ CellsWidthAutoCount++;
3435
+ }
3436
+ }
3437
+
3438
+ var tableFullStyleObj = window.getComputedStyle(table, null);
3439
+ var borderLeftWidth = tableFullStyleObj.getPropertyValue('border-left-width');
3440
+ var borderRightWidth = tableFullStyleObj.getPropertyValue('border-right-width');
3441
+ var tableBorderCommon = parseFloat(borderLeftWidth, 10) + parseFloat(borderRightWidth, 10);
3442
+ tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto + tableBorderCommon;
3443
+
3444
+ table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;
3445
+ if (CellsWidthAutoCount) {
3446
+ table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;
3447
+ if (table.mergingСellsHorizontally) {
3448
+ table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed - tableBorderCommon;
3449
+ } else {
3450
+ table.removeAttribute('data-wptb-fixed-width-size');
3451
+ }
3452
+ } else {
3453
+ table.removeAttribute('data-wptb-fixed-width-size');
3454
+ table.removeAttribute('data-wptb-cells-width-auto-count');
3455
+ }
3456
+
3457
+ var styleElementCreate = false;
3458
+ var tableTdWidthAuto = void 0;
3459
+ if (tableTdsSumMaxWidth < wptbTableSetupWidth) {
3460
+ if (CellsWidthAutoCount) {
3461
+ table.style.minWidth = '100%';
3462
+ if (table.mergingСellsHorizontally) {
3463
+ table.style.width = null;
3464
+ var tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed - tableBorderCommon;
3465
+ tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
3466
+ tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
3467
+ styleElementCreate = true;
3468
+ } else {
3469
+ table.style.width = '100%';
3470
+ }
3471
+ } else {
3472
+ table.style.width = null;
3473
+ table.style.minWidth = null;
3474
+ table.style.maxWidth = tableTdsSumMaxWidth + 'px';
3475
+ }
3476
+ } else {
3477
+ table.style.maxWidth = null;
3478
+ table.style.minWidth = tableTdsSumMaxWidth + 'px';
3479
+ table.style.width = null;
3480
+ tableTdWidthAuto = '100';
3481
+ styleElementCreate = true;
3482
+ }
3483
+
3484
+ var head = document.head;
3485
+ if (head) {
3486
+ var cssForTdsWidthAutoOld = head.querySelector('style[data-wptb-td-auto-width="true"]');
3487
+ if (cssForTdsWidthAutoOld) {
3488
+ head.removeChild(cssForTdsWidthAutoOld);
3489
+ }
3490
+ }
3491
+
3492
+ if (styleElementCreate) {
3493
+ cssForTdsWidthAuto = document.createElement('style');
3494
+ cssForTdsWidthAuto.setAttribute('data-wptb-td-auto-width', true);
3495
+ cssForTdsWidthAuto.innerHTML = '[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';
3496
+ if (head) {
3497
+ head.appendChild(cssForTdsWidthAuto);
3498
+ }
3499
+ }
3500
+ };
3501
+
3502
+ table.addRowHeight = function (value, cleaner) {
3503
+ var highlighted = table.getElementsByClassName('wptb-highlighted');
3504
+ if (highlighted.length > 0) {
3505
+ for (var _k4 = 0; _k4 < highlighted.length; _k4++) {
3506
+ var dataYIndex = highlighted[_k4].dataset.yIndex;
3507
+ if (dataYIndex) {
3508
+ (function () {
3509
+ var tableTdsFor = function tableTdsFor(dataYIndex, rowspan) {
3510
+ var tableRows = table.rows;
3511
+ var heightIsSet = false;
3512
+ var arrayTdsPrevious = [];
3513
+ for (var _i8 = 0; _i8 < tableRows.length; _i8++) {
3514
+ var _row2 = tableRows[_i8];
3515
+ var tds = _row2.children;
3516
+ for (var _j3 = 0; _j3 < tds.length; _j3++) {
3517
+ var td = tds[_j3];
3518
+ if (td.dataset.yIndex == dataYIndex) {
3519
+ if (value) {
3520
+ if (td.rowSpan == rowspan) {
3521
+ td.style.height = value + 'px';
3522
+ td.removeAttribute('data-wptb-fixed-heidht');
3523
+ heightIsSet = true;
3524
+ var tableColumnHeightAutoFixedCheckbox = document.getElementById('wptb-table-row-height-auto-fixed');
3525
+ if (!tableColumnHeightAutoFixedCheckbox.checked) {
3526
+ tableColumnHeightAutoFixedCheckbox.checked = true;
3527
+ }
3528
+ continue;
3529
+ } else {
3530
+ td.style.height = null;
3531
+ td.dataset.wptbFixedHeight = value;
3532
+ if (_j3 == tds.length - 1 && !heightIsSet) {
3533
+ tableTdsFor(dataYIndex, rowspan + 1);
3534
+ }
3535
+ }
3536
+ } else if (cleaner) {
3537
+ td.style.height = null;
3538
+ td.removeAttribute('data-wptb-fixed-heidht');
3539
+ } else {
3540
+ if (td.dataset.wptbFixedHeight) {
3541
+ if (td.rowSpan = rowspan) {
3542
+ td.style.height = td.dataset.wptbFixedHeight + 'px';
3543
+ td.removeAttribute('data-wptb-fixed-width');
3544
+ }
3545
+ } else if (td.style.height) {
3546
+ for (var z = 0; z < arrayTdsPrevious.length; z++) {
3547
+ arrayTdsPrevious[z].style.height = td.style.height;
3548
+ }
3549
+ arrayTdsPrevious = [];
3550
+ } else {
3551
+ arrayTdsPrevious.push(td);
3552
+ }
3553
+ }
3554
+ }
3555
+ }
3556
+ }
3557
+ };
3558
+
3559
+ tableTdsFor(dataYIndex, 1);
3560
+ })();
3561
+ }
3562
+ }
3563
+ }
3564
+ };
3565
+
3566
+ table.reconstraction = function () {
3567
+ var tds = table.getElementsByTagName('td');
3568
+ table.mergingСellsHorizontally = false;
3569
+ table.mergingCellsVertically = false;
3570
+ table.dataset.reconstraction = 1;
3571
+ var forBreak = 0;
3572
+ for (var _i9 = 0; _i9 < tds.length; _i9++) {
3573
+ if (tds[_i9].colSpan > 1) {
3574
+ table.dataset.reconstraction = 0;
3575
+ table.mergingСellsHorizontally = true;
3576
+ forBreak++;
3577
+ }
3578
+
3579
+ if (tds[_i9].rowSpan > 1) {
3580
+ table.dataset.reconstraction = 0;
3581
+ table.mergingCellsVertically = true;
3582
+ forBreak++;
3583
+ }
3584
+
3585
+ if (forBreak == 2) {
3586
+ break;
3587
+ }
3588
+ }
3589
  };
3590
 
3591
  /*
3603
  if (currentTableTd) {
3604
  currentTdStyle = currentTableTd.getAttribute('style');
3605
  }
3606
+
3607
  for (var i = 0; i < table.rows.length; i++) {
3608
  td = new WPTB_Cell(mark);
3609
+
3610
  if (currentTdStyle) {
3611
  td.getDOMElement().setAttribute('style', currentTdStyle);
3612
+ td.getDOMElement().style.width = null;
3613
  }
3614
+
3615
  table.rows[i].appendChild(td.getDOMElement());
3616
  array[i].push(0);
3617
  }
3618
+
3619
  maxAmountOfCells++;
3620
  table.recalculateIndexes();
3621
+ table.tdDefaultWidth();
3622
+ table.addRowHeight();
3623
  WPTB_Helper.dataTitleColumnSet(table);
3624
  undoSelect();
3625
  };
3641
  if (currentTableTd) {
3642
  currentTdStyle = currentTableTd.getAttribute('style');
3643
  }
3644
+
3645
  for (var i = 0; i < table.rows.length; i++) {
3646
  td = new WPTB_Cell(mark);
3647
  if (currentTdStyle) {
3648
  td.getDOMElement().setAttribute('style', currentTdStyle);
3649
+ td.getDOMElement().style.width = null;
3650
  }
3651
  firstCell = table.rows[i].getElementsByTagName('td')[0];
3652
  if (firstCell) {
3659
 
3660
  maxAmountOfCells++;
3661
  table.recalculateIndexes();
3662
+ table.tdDefaultWidth();
3663
+ table.addRowHeight();
3664
  WPTB_Helper.dataTitleColumnSet(table);
3665
  undoSelect();
3666
  };
3705
  td = new WPTB_Cell(mark);
3706
  if (cellStyle) {
3707
  td.getDOMElement().setAttribute('style', cellStyle);
3708
+ td.getDOMElement().style.width = null;
3709
  }
3710
  if (currentCell && rows[i].contains(currentCell)) {
3711
  bro = currentCell.nextSibling;
3757
  maxAmountOfCells++;
3758
  drawTable(array);
3759
  table.recalculateIndexes();
3760
+ table.addColumnWidth();
3761
+ table.addRowHeight();
3762
  WPTB_Helper.dataTitleColumnSet(table);
3763
  undoSelect();
3764
  }
3814
  array.push(aux);
3815
  drawTable(array);
3816
  table.recalculateIndexes();
3817
+ table.addColumnWidth();
3818
  WPTB_Helper.dataTitleColumnSet(table);
3819
  undoSelect();
3820
  };
3851
  array.push(aux);
3852
  drawTable(array);
3853
  table.recalculateIndexes();
3854
+ table.addColumnWidth();
3855
  WPTB_Helper.dataTitleColumnSet(table);
3856
  undoSelect();
3857
  };
3867
  cellStyle = cell.getAttribute('style'),
3868
  row = getCoords(cell)[0],
3869
  cellNew = void 0;
3870
+ for (var _i10 = row - 1; _i10 >= 0; _i10--) {
3871
+ var rowChildren = table.rows[_i10].children;
3872
  var rowChildrenLength = rowChildren.length;
3873
  if (rowChildrenLength > 0) {
3874
+ for (var _j4 = 0; _j4 < rowChildrenLength; _j4++) {
3875
+ if (rowChildren[_j4].rowSpan == 1) {
3876
+ row = _i10;
3877
  cellNew = true;
3878
  break;
3879
  }
3915
 
3916
  var cellsColSpan = 0;
3917
  if (rowAfter < table.rows.length - 1) {
3918
+ for (var _i11 = 0; _i11 <= rowAfter; _i11++) {
3919
+ var tableRowsIChildren = table.rows[_i11].children,
3920
  tableRIChildrenLength = tableRowsIChildren.length;
3921
  if (tableRIChildrenLength > 0) {
3922
+ for (var _j5 = 0; _j5 < tableRIChildrenLength; _j5++) {
3923
+ var rowIRowSpan = tableRowsIChildren[_j5].rowSpan;
3924
 
3925
+ if (rowIRowSpan - 1 + _i11 > rowAfter) {
3926
+ tableRowsIChildren[_j5].rowSpan++;
3927
  }
3928
  }
3929
  }
3934
  rNextChildrenLength = rNextChildren.length;
3935
 
3936
  if (rNextChildrenLength > 0) {
3937
+ for (var _i12 = 0; _i12 < rNextChildrenLength; _i12++) {
3938
+ cellsColSpan += rNextChildren[_i12].colSpan;
3939
  }
3940
  }
3941
  } else {
3948
  for (j = 0; j < cellsColSpan; j++) {
3949
  var td = new WPTB_Cell(mark);
3950
  td.getDOMElement().setAttribute('style', cellStyle);
3951
+ td.getDOMElement().style.width = null;
3952
+ td.getDOMElement().style.height = null;
3953
  r.appendChild(td.getDOMElement());
3954
  }
3955
 
3957
  array.push(aux);
3958
  drawTable(array);
3959
  table.recalculateIndexes();
3960
+ table.addColumnWidth();
3961
  WPTB_Helper.dataTitleColumnSet(table);
3962
  undoSelect();
3963
  };
4046
  tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),
4047
  tdsChildrenNew = [];
4048
 
4049
+ for (var _i13 = 0; _i13 < tds.length; _i13++) {
4050
+ var tdsInternalElements = tds[_i13].getElementsByClassName('wptb-ph-element');
4051
  if (tdsInternalElements.length > 0) {
4052
  var tdsIntElemLength = tdsInternalElements.length;
4053
+ for (var _j6 = 0; _j6 < tdsIntElemLength; _j6++) {
4054
+ tdsChildrenNew.push(tdsInternalElements[_j6]);
4055
  }
4056
  }
4057
+ var p = tds[_i13].parentNode;
4058
+ p.removeChild(tds[_i13]);
4059
  }
4060
  if (tdsChildrenNew.length > 0) {
4061
+ for (var _i14 = 0; _i14 < tdsChildrenNew.length; _i14++) {
4062
+ first.appendChild(tdsChildrenNew[_i14]);
4063
  }
4064
  }
4065
 
4066
  first.colSpan = colspan;
4067
  first.rowSpan = rowspan;
4068
  table.recalculateIndexes();
4069
+ table.reconstraction();
4070
+ var firstWidth = first.style.width;
4071
+ var firstDataFixedWidth = first.dataset.wptbFixedWidth;
4072
+ if (firstWidth) {
4073
+ table.addColumnWidth(parseFloat(firstWidth, 10));
4074
+ } else if (firstDataFixedWidth) {
4075
+ table.addColumnWidth();
4076
+ } else {
4077
+ table.addColumnWidth(false, true);
4078
+ }
4079
+
4080
+ var firstHeight = first.style.height;
4081
+ var firstDataFixedHeight = first.dataset.wptbFixedHeight;
4082
+ if (firstHeight) {
4083
+ table.addRowHeight(parseFloat(firstHeight, 10));
4084
+ } else if (firstDataFixedHeight) {
4085
+ table.addRowHeight();
4086
+ } else {
4087
+ table.addRowHeight(false, true);
4088
+ }
4089
  WPTB_Helper.dataTitleColumnSet(table);
4090
  undoSelect();
4091
  };
4109
  cell.rowSpan = 1;
4110
  cell.colSpan = 1;
4111
 
4112
+ for (var _i15 = 1; _i15 < colspan; _i15++) {
4113
  var td = new WPTB_Cell(mark);
4114
  td.getDOMElement().setAttribute('style', cellStyles);
4115
+ td.getDOMElement().classList.add('wptb-highlighted');
4116
  if (cell.nextSibling) {
4117
  thisRow.insertBefore(td.getDOMElement(), cell.nextSibling);
4118
  } else {
4121
  }
4122
 
4123
  if (rowspan > 1) {
4124
+ for (var _i16 = 1; _i16 < rowspan; _i16++) {
4125
  var rowChildInsertBefore = undefined,
4126
+ rowNext = table.rows[row + _i16],
4127
  rowChildren = rowNext.children,
4128
  rowChildrenLength = rowChildren.length;
4129
 
4130
  if (rowChildrenLength > 0) {
4131
+ for (var _k5 = 0; _k5 < rowChildrenLength; _k5++) {
4132
+ if (Number(rowChildren[_k5].dataset.xIndex) > Number(cellXIndex)) {
4133
+ rowChildInsertBefore = rowChildren[_k5];
4134
  break;
4135
  }
4136
  }
4137
  }
4138
+ for (var _j7 = 0; _j7 < colspan; _j7++) {
4139
  var _td = new WPTB_Cell(mark);
4140
  _td.getDOMElement().setAttribute('style', cellStyles);
4141
  if (rowChildInsertBefore != undefined) {
4148
  }
4149
 
4150
  table.recalculateIndexes();
4151
+ table.reconstraction();
4152
+ table.addColumnWidth();
4153
+ table.addRowHeight();
4154
  WPTB_Helper.dataTitleColumnSet(table);
4155
  undoSelect();
4156
  };
4236
 
4237
  if (rowspan == undefined) rowspan = 1;
4238
 
4239
+ for (var _i17 = 0; _i17 < rowspan; _i17++) {
4240
  thisRow = table.rows[row];
4241
  var thisRowChildren = thisRow.children,
4242
  nextRow = table.rows[row + 1],
4247
  if (nextRow != undefined) {
4248
  nextRowChildren = nextRow.children;
4249
  nextRowChildrenLength = nextRowChildren.length;
4250
+ for (var _j8 = 0; _j8 < thisRowChildren.length; _j8++) {
4251
+ if (thisRowChildren[_j8].rowSpan > 1) {
4252
  var td = new WPTB_Cell(mark);
4253
  td.getDOMElement().setAttribute('style', cellStyles);
4254
+ td.getDOMElement().colSpan = thisRowChildren[_j8].colSpan;
4255
+ td.getDOMElement().rowSpan = thisRowChildren[_j8].rowSpan - 1;
4256
 
4257
  var nextRowChildrenK = undefined;
4258
+ for (var _k6 = 0; _k6 < nextRowChildrenLength; _k6++) {
4259
+ if (Number(nextRowChildren[_k6].dataset.xIndex) > Number(thisRowChildren[_j8].dataset.xIndex)) {
4260
+ nextRowChildrenK = nextRowChildren[_k6];
4261
  break;
4262
  }
4263
  }
4271
  }
4272
 
4273
  if (tdArr.length > 0) {
4274
+ for (var _k7 = 0; _k7 < tdArr.length; _k7++) {
4275
+ if (tdArr[_k7][1] != undefined) {
4276
+ nextRow.insertBefore(tdArr[_k7][0].getDOMElement(), tdArr[_k7][1]);
4277
  } else {
4278
+ nextRow.appendChild(tdArr[_k7][0].getDOMElement());
4279
  }
4280
  }
4281
  }
4283
 
4284
  var tableRows = table.rows;
4285
  if (tableRows.length > 0) {
4286
+ for (var _j9 = 0; _j9 < row; _j9++) {
4287
+ var jRowChildren = tableRows[_j9].children;
4288
  if (jRowChildren.length > 0) {
4289
  for (var x = 0; x < jRowChildren.length; x++) {
4290
+ if (jRowChildren[x].rowSpan - 1 >= row - _j9) {
4291
  jRowChildren[x].rowSpan--;
4292
  }
4293
  }
4323
  cellXIndex = cell.dataset.xIndex,
4324
  colspan = cell.colSpan;
4325
 
4326
+ for (var _i18 = 0; _i18 < colspan; _i18++) {
4327
+ for (var _j10 = 0; _j10 < table.rows.length; _j10++) {
4328
+ var rowChildren = table.rows[_j10].children;
4329
  var rowChildrenLength = rowChildren.length;
4330
  if (rowChildrenLength > 0) {
4331
+ for (var _k8 = rowChildrenLength - 1; _k8 >= 0; _k8--) {
4332
+ if (Number(rowChildren[_k8].dataset.xIndex) == Number(cellXIndex)) {
4333
+ if (rowChildren[_k8].colSpan > 1) {
4334
+ rowChildren[_k8].colSpan--;
4335
  } else {
4336
+ table.rows[_j10].removeChild(rowChildren[_k8]);
4337
  }
4338
  break;
4339
+ } else if (Number(rowChildren[_k8].dataset.xIndex) < Number(cellXIndex) && Number(rowChildren[_k8].dataset.xIndex) + Number(rowChildren[_k8].colSpan - 1) >= cellXIndex) {
4340
+ if (rowChildren[_k8].colSpan > 1) {
4341
+ rowChildren[_k8].colSpan--;
4342
  }
4343
  break;
4344
  }
4346
  }
4347
  }
4348
 
4349
+ for (var _j11 = 0; _j11 < table.rows.length; _j11++) {
4350
+ if (array[_j11] != undefined) array[_j11].pop();
4351
  }
4352
 
4353
  maxAmountOfCells--;
4360
  }
4361
 
4362
  table.recalculateIndexes();
4363
+ table.tdDefaultWidth();
4364
  WPTB_Helper.dataTitleColumnSet(table);
4365
  }
4366
  undoSelect();
4377
  //if (columns || rows) {
4378
  table.recalculateIndexes(true);
4379
  //}
4380
+ table.reconstraction();
4381
+ table.tdDefaultWidth();
4382
+
4383
+ wptbTableSetup.onresize = function () {
4384
+ table.tdDefaultWidth();
4385
+ };
4386
 
4387
  WPTB_LeftPanel();
4388
 
4455
 
4456
  return this;
4457
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4458
  //# sourceMappingURL=admin.js.map
inc/admin/js/admin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["WPTB_Builder.js","WPTB_Button.js","WPTB_Cell.js","WPTB_DropHandle.js","WPTB_ElementCounters.js","WPTB_ElementOptions.js","WPTB_Helper.js","WPTB_Image.js","WPTB_Initializer.js","WPTB_LeftPanel.js","WPTB_List.js","WPTB_ListItem.js","WPTB_MultipleSelect.js","WPTB_Parser.js","WPTB_Parser2.js","WPTB_Settings.js","WPTB_Space.js","WPTB_Stringifier.js","WPTB_Stringifier2.js","WPTB_Table.js","WPTB_Text.js","WPTB_innerElementSet.js","applyGenericItemSettings.js","wptb-builder.js"],"names":["WPTB_Builder","table_id","WPTB_Helper","detectMode","http","XMLHttpRequest","urlSet","ajaxurl","open","setRequestHeader","onreadystatechange","d","readyState","status","ans","JSON","parse","responseText","document","getElementById","value","getElementsByClassName","style","display","wptbTableSetupEl","appendChild","WPTB_Parser","WPTB_Table","WPTB_LeftPanel","WPTB_Settings","send","counter","ElementCounters","select","MultipleSelect","initializer","WPTB_Initializer","settings","addEventListener","WPTB_Button","text","DOMElementProt","DOMElement","createElement","elButton","el_B","el_BDiv","kindIndexProt","undefined","copy","classList","add","innerHTML","wptbElementMutch","className","match","Array","isArray","attributesContainer","attributes","length","i","setAttribute","name","wptbButtonWrapper","querySelector","wptbButtonWrapAttributes","wptbButton","wptbButtonAttributes","kind","getDOMElement","applyGenericItemSettings","WPTB_Cell","callback","highlightRow","td","parentRow","parentNode","columnCount","parseInt","tds","getElementsByTagName","remove","classToAdd","ttd","highlightColumn","index","rowCount","table","tr","padding","jQuery","val","innerBorderWidth","border","draggable","onclick","WPTB_innerElementSet","wptbPhElement","wptbSpaceBetween","j","WPTB_Space","wptbElementTypeClass","wptbTypeElementArr","split","wptbListItems","WPTB_ListItem","setCoords","y","x","el","dataset","yIndex","xIndex","getCoords","coords","appendElement","node","WPTB_DropHandle","thisElem","e","newElementProxy","includes","WPTB_List","WPTB_Image","WPTB_Text","wptbDropHandle","wptbDropBorderMarker","wptbDropBorderMarkerTop","wptbDropBorderMarkerRight","wptbDropBorderMarkerBottom","wptbDropBorderMarkerLeft","body","ondragenter","ondragover","preventDefault","ondragleave","ondrop","element","dataTransfer","getData","getDOMParentElement","nodeName","toLowerCase","innerElement","insertBefore","innerElementNext","nextSibling","thisRow","contains","findAncestor","dataTitleColumnSet","wptbContainer","onscroll","localName","indics","types","notDragEnter","infArr","width","offsetWidth","height","offsetHeight","coordinatesElement","getBoundingClientRect","left","Number","top","indexOf","elementDrag","offsetY","layerY","bottom","priv","increment","key","nextIndex","WPTB_ElementOptions","elemIdClass","prop","cloneNode","properties","affectedEl","wptbButtonA","wptbSize","b","buttonAlignment","justifyContent","buttonAlignmentSelect","selectOption","selectOptionVal","selected","buttonHref","getAttribute","buttonLinkTarget","buttonId","buttonHrefInput","buttonLinkTargetInput","buttonLinkTargetInputId","buttonLinkTargetInputLabel","buttotIdInput","checked","buttonTextColor","color","buttonColor","backgroundColor","buttonTextColorInput","buttonBackgroundColorInput","rgbToHex","elementsA","a","aTextAlign","textAlign","imageAlignmentSelect","imageLinkHref","inputImageLink","imageLinkTarget","imageLinkTargetInput","imageLinkTargetInputId","imageLinkTargetInputLabel","img","imgWidth","imageWidthInputRange","imageWidthInputNumber","imgAlternativeText","imageAlternativeTextInput","elementFontSize","fontSize","elementTextColor","textFontSizeInputRange","textFontSizeInputNumber","textColorInput","elementList","elementListColor","listColorInput","elementListItem","querySelectorAll","listItemP","listItemPClasses","elementListClassSelect","listIconSelectLabel","nodeType","listIconSelectLabelId","elementListStyleTypeSelect","elementListItemContent","listItemPTextAlignArr","p","push","listItemPTextAlignLeftCount","listItemPTextAlignCenterCount","listItemPTextAlignRightCount","elementListAlignmentSelect","maxListItemTAlLeftC","Math","max","optionsClass","children","childNodes","buttons","size","n_Class","type","num","optionControls","wpColorPicker","change","event","ui","parent","target","classe","ps","number","toString","slider","oninput","onchange","src","alt","href","linkHttpCheckChange","rel","removeAttribute","jc","id","listItems","parentNodeSettingItem","listItem","hexToRgb","hex","result","exec","rgb","slice","getDragImageCustom","hostName","location","protocol","hostname","dragImagesArr","image","button","list","listItemsRecalculateIndex","ulElem","par","listStyleTypeIndex","listItemsTinyMceInit","tinyMCE","init","inline","plugins","dialog_type","theme","menubar","fixed_toolbar_container","paste_as_text","toolbar","setup","ed","on","article","keyCode","duplicate","firstChild","innerText","pText","replace","trim","selectedText","getSelectionText","init_instance_callback","editor","window","currentEditor","totalWidth","scrollTop","bodyElement","position","right","buttonsTinyMceInit","link","linkArr","linkClean","rows","rowHead","computedStyleRowHead","getComputedStyle","rowHeadChildren","contentsForHeader","tdElements","textContentStyle","textContent","thisRowChildren","titleColumn","titleColumnFontSize","titleColumnColor","titleBackgroundColor","titleAlign","cls","parentElement","txt","getSelection","selection","createRange","settingsPanelClear","wpColorPickerClear","inputId","input","wpPickerContainer","removeChild","newInput","url","regex","RegExp","results","decodeURIComponent","anchor","file_frame","wp","media","frames","title","multiple","attachment","state","get","first","toJSON","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","columns","wptbElementButtons","wptbTdBgColorSavedSet","trNumber","tableRows","trBackgroundColor","wptbEvenRowBg","clear","tableHeader","tableTopRowAsHeadSavedSet","wptbTopRowAsHeader","tableBorderColorWidthSavedSet","tableBorderColor","borderColor","tableBorderColorInput","tableBorderWidth","borderWidth","wptbTableBorderWidthSlider","wptbTableBorderWidthNumber","tableTd","applyInnerBorder","innerBorderCheckInput","wptbApplyInnerBorder","wptbTableInnerBorderSlider","wptbTableInnerBorderNumber","tableCells","tableInnerborderNumber","addInnerBorderSize","borderStyle","addCellPadding","addInnerBorder","styles","wptbPreviewTable","marginBottom","addBorderSize","cellPaddingSavedSet","wptbTableCellSlider","wptbTableCellNumber","numberImputSize","wptbNumberInputs","maxCount","maxValue","onkeydown","thisValue","String","substring","onkeyup","wptbTableBorderNumber","wptbTextfontSizeNumber","wptbImageWidthNumber","wptbInnerBorderCheck","tableBorderColorSetArea","createMobileHeadForTable","thisEvent","ondragstart","setData","wptbElement","toggleTableEditMode","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","wpcdFixedToolbar","hasAttribute","innerElements","el_L","item","wptbListItemReturn","divcontent","styleDot","listItemKeyListener","onmouseenter","btnDelete","btnCopy","actions","previous","action","content","html","setTimeout","append","onmouseleave","iter","selectedCells","multipleCellMode","activateMultipleSelectMode","deactivateMultipleSelectMode","isActivated","pushSelectedCell","cell","flushSelectedCells","getFirst","minXIndex","minYIndex","getLast","maxXIndex","maxYIndex","last","removeAllButFirst","code","div","columnTitleMobile","WPTB_Parser2","elementHtml","createTextNode","tagName","elems","effectAllowed","ondragend","shortcodePopupWindow","bar","wptb_admin_object","t","messagingArea","WPTB_Stringifier","outerHTML","messagingAreaText","params","security_code","rs","wptbId","stringify","data","elSpaceBetween","spaceBetween","stopPropagation","t_space","spaceParent","alert","codeMain","tableColumns","reconstraction","colSpan","rowSpan","mceContentBodys","k","dataMceStyle","contentEditable","spellCheck","mceIds","wptbActions","wptbActionsLength","columnNameDivContainer","columnNameDiv","WPTB_Stringifier2","start","nodeValue","int_elem_arr","attributes_list","internal_elements","inter_elem","array","wptbTableSetup","row","maxAmountOfCells","maxAmountOfRows","mark","cs","markedCells","noCells","singleCells","multipleCells","column","isSquare","realTimeArray","carried","cols","matriz","items","justAssigned","amount","carriedRowspans","cellsBuffer","cellPointer","xPosition","stepsToMove","celda","drawTable","string","undoSelect","fillTableArray","colspansSums","cells","colspanSumInRow","apply","getActualPointsInRow","points","search","skipInCols","insertRow","wptb_preview_table","cellModeBackground","leftScrollPanelCurtain","wptbPreviewTableTds","recalculateIndexes","trs","maxCols","tdsArr","jMainIter","z","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","rowspan","colspan","call","tdsChildrenNew","tdsInternalElements","tdsIntElemLength","cellStyles","cellXIndex","rowChildInsertBefore","rowNext","findRowspannedCells","difference","actualPoints","addLackingCells","sumRows","totalColspan","nextRow","nextRowChildren","nextRowChildrenLength","tdArr","nextRowChildrenK","jRowChildren","pop","elText2","elP","classId","onmouseover","wptbElements","elementIndexesArr","elementIndexMax","btnMove","act","temp","srcList","opacity","setDragImage","observer","MutationObserver","mutations","config","attributeFilter","observe","node_wptb_element_kind_num"],"mappings":"AAAA,CAAC,YAAY;AACT,QAAIA,eAAe,SAAfA,YAAe,GAAY;AAC3B,YAAIC,WAAWC,YAAYC,UAAZ,EAAf;AACA,YAAKF,QAAL,EAAgB;AACZ,gBAAIG,OAAO,IAAIC,cAAJ,EAAX;AAAA,gBACIC,SAASC,UAAU,mBAAV,GAAgC,MAAhC,GAAyCN,QADtD;AAEAG,iBAAKI,IAAL,CAAU,KAAV,EAAiBF,MAAjB,EAAyB,IAAzB;AACAF,iBAAKK,gBAAL,CAAsB,cAAtB,EAAsC,mCAAtC;AACAL,iBAAKM,kBAAL,GAA0B,UAAUC,CAAV,EAAa;AACnC,oBAAI,KAAKC,UAAL,IAAmB,CAAnB,IAAwB,KAAKC,MAAL,IAAe,GAA3C,EAAgD;AAC5C,wBAAIC,MAAMC,KAAKC,KAAL,CAAWZ,KAAKa,YAAhB,CAAV;AACAC,6BAASC,cAAT,CAAwB,iBAAxB,EAA2CC,KAA3C,GAAmDN,IAAI,CAAJ,CAAnD;;AAEA,wBAAIA,IAAI,CAAJ,CAAJ,EAAa;AACTI,iCAASG,sBAAT,CAAgC,sBAAhC,EAAwD,CAAxD,EAA2DC,KAA3D,CAAiEC,OAAjE,GAA2E,MAA3E;AACA,4BAAIC,mBAAmBN,SAASG,sBAAT,CAAgC,kBAAhC,EAAoD,CAApD,CAAvB;AACAG,yCAAiBC,WAAjB,CAA8BC,YAAaZ,IAAI,CAAJ,CA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,2BAA2B,CAA3B,CAAvB;AACH;AACD,QAAK,CAAEtjB,KAAKnE,SAAL,CAAemG,QAAf,CAAyB,iBAAzB,CAAP,EAAsD;AAClDhC,aAAKnE,SAAL,CAAeC,GAAf,CAAoB,iBAApB;AACA,YAAI,CAAEkE,KAAKnE,SAAL,CAAemG,QAAf,CAAyB,kBAAkBX,QAAQrE,IAA1B,GAAiC,GAAjC,GAAuCiB,KAAhE,CAAN,EAAgF;AAC5E+B,iBAAKnE,SAAL,CAAeC,GAAf,CAAoB,kBAAkBuF,QAAQrE,IAA1B,GAAiC,GAAjC,GAAuCiB,KAA3D;AACH;AACJ,KALD,MAKO;AACH,YAAI,CAAE+B,KAAKnE,SAAL,CAAemG,QAAf,CAAyB,kBAAkBX,QAAQrE,IAA1B,GAAiC,GAAjC,GAAuCiB,KAAhE,CAAN,EAAgF;AAC5E+B,iBAAKnE,SAAL,CAAeC,GAAf,CAAoB,kBAAkBuF,QAAQrE,IAA1B,GAAiC,GAAjC,GAAuCiB,KAA3D;AACH;AACJ;AACD,QAAI2F,mBAAJ,CAAyBvC,OAAzB,EAAkCpD,KAAlC,EAAyCvC,aAAzC;;AAEA7B,aAASa,OAAT,CAAiB+I,SAAjB,CAA2BpC,QAAQrE,IAAnC;AACH,CAnND;ACAA","file":"admin.js","sourcesContent":["(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 WPTB_Table();\n WPTB_LeftPanel();\n WPTB_Settings();\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_Button = function( text, DOMElementProt ) {\n \n var DOMElement = document.createElement('div'),\n elButton = document.createElement('div'),\n el_B = document.createElement('a'),\n el_BDiv = document.createElement( 'div' ),\n kindIndexProt = undefined,\n copy = false;\n\n DOMElement.classList.add('wptb-button-container', 'wptb-size-M', 'wptb-');\n elButton.classList.add('wptb-button-wrapper');\n el_BDiv.classList.add('wptb-button');\n el_BDiv.innerHTML = text != undefined ? text : 'Button Text';\n \n // Creation of a new button when copying to avoid errors when assigning new event handlers.\n if ( DOMElementProt ) {\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n copy = true;\n }; \n var attributesContainer = [...DOMElementProt.attributes];\n if ( attributesContainer.length > 0 ) {\n for( let i = 0; i < attributesContainer.length; i++ ) {\n DOMElement.setAttribute(attributesContainer[i].name, attributesContainer[i].value);\n } \n }\n \n var wptbButtonWrapper = DOMElementProt.querySelector( '.wptb-button-wrapper' );\n if ( wptbButtonWrapper ) {\n var wptbButtonWrapAttributes = [...wptbButtonWrapper.attributes];\n if ( wptbButtonWrapAttributes.length > 0 ) {\n for( let i = 0; i < wptbButtonWrapAttributes.length; i++ ) {\n if ( wptbButtonWrapAttributes[i].name == 'style') {\n elButton.setAttribute( wptbButtonWrapAttributes[i].name, wptbButtonWrapAttributes[i].value );\n }\n } \n }\n }\n \n var wptbButton = DOMElementProt.querySelector( 'a' );\n if ( wptbButton ) {\n var wptbButtonAttributes = [...wptbButton.attributes];\n if ( wptbButtonAttributes.length > 0 ) {\n for( let i = 0; i < wptbButtonAttributes.length; i++ ) {\n if ( wptbButtonAttributes[i].name == 'style' || \n wptbButtonAttributes[i].name == 'href' || \n wptbButtonAttributes[i].name == 'target' ) {\n el_B.setAttribute( wptbButtonAttributes[i].name, wptbButtonAttributes[i].value );\n }\n } \n }\n }\n }\n \n elButton.appendChild(el_B);\n el_B.appendChild( el_BDiv );\n DOMElement.appendChild(elButton);\n \n \n \n this.kind = 'button';\n\n this.getDOMElement = function () {\n return DOMElement;\n };\n\n applyGenericItemSettings( this, kindIndexProt, copy );\n\n return this;\n};","var WPTB_Cell = function (callback, DOMElement) {\n\n function highlightRow(td) {\n var parentRow = td.parentNode,\n columnCount = parseInt(document.getElementById('wptb-columns-number').value),\n tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n tds[i].classList.remove('wptb-highlighted-row-first', 'wptb-highlighted-row-last', 'wptb-highlighted-row-inner', 'wptb-highlighted-column-first', 'wptb-highlighted-column-last', 'wptb-highlighted-column-inner');\n }\n for (var i = 0; i < columnCount; i++) {\n\n var classToAdd = i == 0 ? 'wptb-highlighted-row-first' : i == columnCount - 1 ? 'wptb-highlighted-row-last' : 'wptb-highlighted-row-inner';\n var ttd = parentRow.getElementsByTagName('td')[i];\n if (ttd !== td) {\n ttd.classList.add(classToAdd);\n }\n }\n }\n\n function highlightColumn(td) {\n\n var index,\n parentRow = td.parentNode;\n columnCount = parseInt(document.getElementById('wptb-columns-number').value), rowCount = parseInt(document.getElementById('wptb-rows-number').value), table = document.getElementsByClassName('wptb-preview-table')[0];\n for (var i = 0; i < columnCount; i++) {\n if (parentRow.getElementsByTagName('td')[i] === td) {\n index = i;\n break;\n }\n }\n\n for (var i = 0; i < rowCount; i++) {\n var classToAdd = i == 0 ? 'wptb-highlighted-column-first' : i == rowCount - 1 ? 'wptb-highlighted-column-last' : 'wptb-highlighted-column-inner';\n var tr = table.getElementsByTagName('tr')[i];\n if (tr.getElementsByTagName('td')[index] !== td) {\n tr.getElementsByTagName('td')[index].classList.add(classToAdd);\n }\n }\n }\n \n if( ! DOMElement ) {\n DOMElement = document.createElement(\"td\");\n\n DOMElement.style.padding = jQuery('#wptb-table-padding-number').val() + 'px';\n\n var innerBorderWidth = jQuery('#wptb-table-inner-border-number').val();\n\n if (innerBorderWidth != '' && parseInt(innerBorderWidth) != 0) {\n DOMElement.style.border = innerBorderWidth + 'px solid ' + jQuery('#wptb-table-border-color').val();\n } \n\n DOMElement.classList.add('wptb-droppable', 'wptb-cell');\n }\n\n DOMElement.draggable = false;\n if ( callback ) {\n DOMElement.onclick = callback;\n }\n \n WPTB_innerElementSet( DOMElement );\n \n let wptbPhElement = DOMElement.getElementsByClassName( 'wptb-ph-element' );\n \n if ( wptbPhElement.length > 0 ) {\n for( let i = 0; i < wptbPhElement.length; i++ ) {\n\n let wptbSpaceBetween = DOMElement.getElementsByClassName( 'wptb-space-between' );\n\n if ( wptbSpaceBetween.length > 0 ) {\n for( let j = 0; j < wptbSpaceBetween.length; j++ ) {\n WPTB_Space( wptbSpaceBetween[j] );\n }\n }\n \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 if ( wptbPhElement[i].kind == 'list' ) {\n let wptbListItems = wptbPhElement[i].getElementsByTagName( 'li' );\n if( wptbListItems.length > 0 ) {\n for ( let i = 0; i < wptbListItems.length; i++ ) {\n WPTB_ListItem( undefined, wptbListItems[i] );\n }\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 return this;\n};","var WPTB_DropHandle = function (thisElem, e) {\n \n function newElementProxy(el) {\n if (el.includes('list')) {\n return new WPTB_List();\n } else if (el.includes('image')) {\n return new WPTB_Image();\n } else if (el.includes('text')) {\n return new WPTB_Text();\n } else if (el.includes('button')) {\n return new WPTB_Button();\n }\n }\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 = 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 }\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 == 'Abowe Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n \n WPTB_innerElementSet(element);\n }\n let wptbContainer = document.querySelector( '.wptb-container' );\n wptbContainer.onscroll = function() {\n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n }\n } else {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n if( thisElem && thisElem.nodeName.toLowerCase() == 'td' && \n thisElem.getElementsByClassName( 'wptb-ph-element' ).length != 0 ) {\n return;\n }\n \n let thisRow;\n if ( thisElem.localName == 'td' ) {\n thisRow = thisElem.parentNode;\n } else if ( thisElem.localName == 'div' && thisElem.classList.contains( 'wptb-ph-element' ) ) {\n thisRow = thisElem.parentNode.parentNode;\n }\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let indics = e.dataTransfer.types;\n let notDragEnter = false;\n for ( let i = 0; i < indics.length; i++ ) {\n let infArr = indics[i].match( /wptbelindic-([a-z]+)/i );\n if ( infArr && infArr[1] != 'text' ) {\n notDragEnter = true;\n break;\n }\n }\n if( notDragEnter ) {\n return;\n }\n }\n \n wptbDropHandle.style.width = thisElem.offsetWidth + 'px';\n let height = thisElem.offsetHeight,\n coordinatesElement = thisElem.getBoundingClientRect(),\n left = Number( 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 = Number( coordinatesElement.top ) - Number( 11 );\n wptbDropHandle.dataset.text = 'Abowe Element';\n if ( y > height/2 ) {\n top = Number( coordinatesElement.top ) + height - 1;\n wptbDropHandle.dataset.text = 'Below Element';\n }\n } else {\n wptbDropHandle.dataset.text = 'Drop Here';\n top = Number( 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 = ( Number( thisElem.offsetWidth ) - Number( 1 ) ) + 'px';\n\n wptbDropBorderMarkerRight = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-right' );\n wptbDropBorderMarkerRight.style.height = ( Number( coordinatesElement.bottom ) - Number( 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_ElementOptions = function ( element, index, kindIndexProt ) {\n\n var node = element.getDOMElement(), elemIdClass;\n\n prop = document.querySelector(\".wptb-\" + element.kind + \"-options-prototype\").cloneNode(true);\n prop.classList.remove(\"wptb-\" + element.kind + \"-options-prototype\"); // remove prototype from the class\n elemIdClass = 'wptb-options-' + element.kind + \"-\" + index;\n\n var properties = prop.getElementsByClassName('wptb-element-property');\n\n for (var i = 0; i < properties.length; i++) {\n properties[i].dataset.element = elemIdClass;\n }\n\n prop.classList.add(elemIdClass);\n document.getElementById(\"element-options-group\").appendChild(prop);\n \n if ( kindIndexProt ) {\n if ( element.kind == 'button' ) {\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt )[0],\n wptbButtonWrapper,\n wptbButtonA,\n wptbButton,\n wptbSize;\n \n if ( affectedEl ) {\n wptbSize = affectedEl.className.match(/wptb-size-([a-z]+)/i);\n }\n \n if( wptbSize && Array.isArray( wptbSize ) ) {\n var b = prop.getElementsByClassName('wptb-btn-size-btn');\n \n for ( var i = 0; i < b.length; i++ ) {\n b[i].classList.remove( 'selected' );\n \n if ( b[i].innerHTML == wptbSize[1] ) {\n b[i].classList.add( 'selected' );\n }\n }\n }\n \n if( affectedEl ) {\n wptbButtonWrapper = affectedEl.getElementsByClassName( 'wptb-button-wrapper' );\n \n wptbButtonA = affectedEl.getElementsByTagName( 'a' );\n \n wptbButton = affectedEl.getElementsByClassName( 'wptb-button' );\n }\n \n if ( wptbButtonWrapper ) {\n let buttonAlignment = wptbButtonWrapper[0].style.justifyContent,\n buttonAlignmentSelect = prop.querySelector( 'select[data-type=\"button-alignment\"]' ),\n selectOption = buttonAlignmentSelect.getElementsByTagName( 'option' ),\n selectOptionVal;\n \n if ( buttonAlignment == 'flex-start' ) {\n selectOptionVal = 'left';\n } else if ( buttonAlignment == 'center' || ! buttonAlignment ) {\n selectOptionVal = 'center';\n } else if ( buttonAlignment == 'flex-end' ) {\n selectOptionVal = 'right';\n }\n \n for ( let i = 0; i < selectOption.length; i++ ) {\n if ( selectOption[i].value == selectOptionVal ) {\n selectOption[i].selected = true;\n }\n }\n }\n \n if ( wptbButtonA.length > 0 ) {\n let buttonHref = wptbButtonA[0].getAttribute( 'href' ), \n buttonLinkTarget = wptbButtonA[0].getAttribute( 'target' ),\n buttonId = wptbButtonA[0].getAttribute( 'id' ),\n \n \n buttonHrefInput = prop.querySelector( 'input[data-type=\"button-link\"]' ),\n buttonLinkTargetInput = prop.querySelector( 'input[data-type=\"button-link-target\"]' ),\n buttonLinkTargetInputId = buttonLinkTargetInput.getAttribute( 'id' ),\n buttonLinkTargetInputLabel = buttonLinkTargetInput.parentNode.getElementsByTagName( 'label' )[0],\n \n buttotIdInput = prop.querySelector( 'input[data-type=\"button-id\"]' );\n\n buttonLinkTargetInputId = buttonLinkTargetInputId + '-' + kindIndexProt.split( '-' )[1];\n buttonLinkTargetInput.setAttribute( 'id', buttonLinkTargetInputId );\n buttonLinkTargetInputLabel.setAttribute( 'for', buttonLinkTargetInputId );\n\n buttonHrefInput.value = buttonHref;\n\n if( buttonLinkTarget && buttonLinkTarget == '_blank') {\n buttonLinkTargetInput.checked = true;\n }\n \n buttotIdInput.value = buttonId;\n }\n \n if( wptbButton ) {\n let buttonTextColor = wptbButton[0].style.color,\n buttonColor = wptbButton[0].style.backgroundColor,\n buttonTextColorInput = prop.querySelector( 'input[data-type=\"button-text-color\"]' ),\n buttonBackgroundColorInput = prop.querySelector( 'input[data-type=\"button-color\"]' );\n \n \n buttonTextColorInput.value = WPTB_Helper.rgbToHex( buttonTextColor );\n \n buttonBackgroundColorInput.value = WPTB_Helper.rgbToHex( buttonColor );\n \n }\n } else if ( element.kind == 'image' ) {\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\n if ( affectedEl.length > 0 ) {\n let elementsA = affectedEl[0].getElementsByTagName( 'a' );\n if ( elementsA.length > 0 ) {\n let a = elementsA[0];\n\n if ( a ) {\n a.onclick = function( e ) {\n e.preventDefault();\n }\n // set select according to the alignment of the image\n let aTextAlign = a.style.textAlign,\n imageAlignmentSelect = prop.querySelector( 'select[data-type=\"image-alignment\"]' ),\n selectOption = imageAlignmentSelect.getElementsByTagName( 'option' );\n\n for ( let i = 0; i < selectOption.length; i++ ) {\n if ( selectOption[i].value == aTextAlign ) {\n selectOption[i].selected = true;\n }\n }\n\n // set text link for input field of setting panel\n let imageLinkHref = a.getAttribute( 'href' ),\n inputImageLink = prop.querySelector( 'input[data-type=\"image-link\"]' );\n if ( imageLinkHref ) {\n inputImageLink.value = imageLinkHref;\n }\n\n // set checkbox for target of link \n let imageLinkTarget = a.getAttribute( 'target' ),\n imageLinkTargetInput = prop.querySelector( 'input[data-type=\"image-link-target\"]' ),\n imageLinkTargetInputId = imageLinkTargetInput.getAttribute( 'id' ),\n imageLinkTargetInputLabel = imageLinkTargetInput.parentNode.getElementsByTagName( 'label' )[0];\n\n imageLinkTargetInputId = imageLinkTargetInputId + '-' + kindIndexProt.split( '-' )[1];\n\n imageLinkTargetInput.setAttribute( 'id', imageLinkTargetInputId );\n imageLinkTargetInputLabel.setAttribute( 'for', imageLinkTargetInputId );\n\n if ( imageLinkTarget && imageLinkTarget == '_blank' ) {\n imageLinkTargetInput.checked = true;\n }\n\n let img = a.getElementsByTagName( 'img' );\n if ( img.length > 0 ) {\n // set value for input fields of image size\n let imgWidth = img[0].style.width;\n if ( imgWidth ) {\n let imageWidthInputRange = prop.querySelector( 'input[type=\"range\"][data-type=\"image-size\"]' ),\n imageWidthInputNumber = prop.querySelector( 'input[type=\"number\"][data-type=\"image-size\"]' );\n\n imageWidthInputRange.value = parseInt( imgWidth );\n imageWidthInputNumber.value = parseInt( imgWidth );\n }\n\n // set value for input field of alternative text image\n let imgAlternativeText = img[0].getAttribute('alt'),\n imageAlternativeTextInput = prop.querySelector( 'input[type=\"text\"][data-type=\"alternative-text\"]' );\n\n imageAlternativeTextInput.value = imgAlternativeText;\n }\n }\n }\n }\n } else if ( element.kind == 'text' ) {\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\n if ( affectedEl.length > 0 ) {\n let elementFontSize = affectedEl[0].style.fontSize,\n elementTextColor = affectedEl[0].style.color;\n let textFontSizeInputRange = prop.querySelector( 'input[type=\"range\"][data-type=\"font-size\"]' ),\n textFontSizeInputNumber = prop.querySelector( 'input[type=\"number\"][data-type=\"font-size\"]' ),\n textColorInput = prop.querySelector( 'input[type=\"text\"][data-type=\"color\"]' );\n\n textFontSizeInputRange.value = parseInt( elementFontSize );\n textFontSizeInputNumber.value = parseInt( elementFontSize );\n textColorInput.value = WPTB_Helper.rgbToHex( elementTextColor );\n }\n } else if ( element.kind == 'list' ) {\n let elementList = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\n if ( elementList.length > 0 ) {\n let elementListColor = elementList[0].querySelector( 'p' ).style.color;\n let listColorInput = prop.querySelector( 'input[type=\"text\"][data-type=\"list-text-color\"]' );\n listColorInput.value = WPTB_Helper.rgbToHex( elementListColor );\n \n let elementListItem = elementList[0].querySelectorAll( 'li' );\n if ( elementListItem.length > 0 ) {\n let listItemP = elementListItem[0].querySelector( 'p' );\n let listItemPClasses = listItemP.classList;\n //listItemPClasses = [...listItemPClasses];\n if ( listItemPClasses.length > 0 ) {\n let elementListClassSelect = prop.querySelector( 'select[data-type=\"list-class\"]' );\n if ( elementListClassSelect ) {\n elementListClassSelect.value = 'unordered';\n \n let listIconSelectLabel = elementListClassSelect.parentNode.nextSibling;\n for ( let i = 0; i < 10; i++ ) {\n if ( listIconSelectLabel.nodeType == '1' ) {\n break;\n } else {\n listIconSelectLabel = listIconSelectLabel.nextSibling;\n }\n }\n if ( listIconSelectLabel ) {\n let listIconSelectLabelId = listIconSelectLabel.getAttribute( 'id' );\n listIconSelectLabel.setAttribute( 'id', listIconSelectLabelId + '-' + kindIndexProt );\n listIconSelectLabel.style.display = 'flex';\n }\n \n let elementListStyleTypeSelect = prop.querySelector( 'select[data-type=\"list-style-type\"]' );\n if ( elementListStyleTypeSelect ) {\n elementListStyleTypeSelect.parentNode.style.display = 'flex';\n \n if( listItemPClasses.contains( 'wptb-list-style-type-disc' ) ) {\n elementListStyleTypeSelect.value = 'disc';\n } else if( listItemPClasses.contains( 'wptb-list-style-type-circle' ) ) {\n elementListStyleTypeSelect.value = 'circle';\n } else if( listItemPClasses.contains( 'wptb-list-style-type-square' ) ) {\n elementListStyleTypeSelect.value = 'square';\n } else if ( listItemPClasses.contains( 'wptb-list-style-type-none' ) ) {\n elementListStyleTypeSelect.value = 'none';\n }\n }\n }\n }\n }\n \n let elementListItemContent = elementList[0].getElementsByClassName( 'wptb-list-item-content' );\n if ( elementListItemContent.length > 0 ) {\n let listItemPTextAlignArr = [];\n for ( let i = 0; i < elementListItemContent.length; i++ ) {\n let p = elementListItemContent[i].querySelector( 'p' );\n if ( p ) {\n if ( p.style.textAlign ) {\n listItemPTextAlignArr.push( p.style.textAlign );\n } else {\n listItemPTextAlignArr.push( 'left' );\n }\n }\n \n }\n \n let listItemPTextAlignLeftCount = 0,\n listItemPTextAlignCenterCount = 0,\n listItemPTextAlignRightCount = 0;\n \n if ( listItemPTextAlignArr.length > 0 ) {\n for ( let i = 0; i < listItemPTextAlignArr.length; i++ ) {\n if ( listItemPTextAlignArr[i] ) {\n if ( listItemPTextAlignArr[i] == 'left' ) {\n listItemPTextAlignLeftCount++;\n } else if ( listItemPTextAlignArr[i] == 'center' ) {\n listItemPTextAlignCenterCount++;\n } else if ( listItemPTextAlignArr[i] == 'right' ) {\n listItemPTextAlignRightCount++;\n }\n }\n }\n }\n \n let elementListAlignmentSelect = prop.querySelector( 'select[data-type=\"list-alignment\"]' ),\n maxListItemTAlLeftC = Math.max( listItemPTextAlignLeftCount, listItemPTextAlignCenterCount, listItemPTextAlignRightCount );\n \n if ( listItemPTextAlignLeftCount == maxListItemTAlLeftC ) {\n elementListAlignmentSelect.value = 'left';\n } else if ( listItemPTextAlignCenterCount == maxListItemTAlLeftC ) {\n elementListAlignmentSelect.value = 'center';\n } else if ( listItemPTextAlignRightCount == maxListItemTAlLeftC ) {\n elementListAlignmentSelect.value = 'right';\n }\n }\n } \n }\n }\n\n node.onclick = function () {\n var infArr = this.className.match(/wptb-element-((.+-)\\d+)/i),\n optionsClass = '.wptb-' + infArr[2] + 'options' +\n '.wptb-options-' + infArr[1];\n\n document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';\n document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';\n document.getElementById(\"element-options-group\").style.display = 'block';\n\n var children = document.getElementById(\"element-options-group\").childNodes;\n for (var i = 0; i < children.length; i++) {\n if (children[i].style)\n children[i].style.display = 'none';\n }\n\n document.querySelector(optionsClass).style.display = 'block';\n\n //var listStyleType, textAlign;\n\n// switch (element.kind) {\n\n// case 'text':\n// jQuery(prop).find('[data-type=color]').wpColorPicker({ defaultColor: node.style.color });\n// prop.querySelector('[type=number][data-type=font-size]').value\n// = prop.querySelector('[type=range][data-type=font-size]').value\n// = node.style.fontSize.substring(0, node.style.fontSize.length - 2);\n// break;\n// case 'list':\n// textAlign = node.querySelector('li p').style.textAlign;\n// listStyleType = node.querySelector('li').style.listStyleType;\n// if ( prop.querySelector( 'select[data-type=list-class]' ) ) {\n// console.log(textAlign);\n// console.log(listStyleType);\n// console.log(listStyleType);\n// console.log(prop);\n// prop.querySelector('select[data-type=list-class]').selectedIndex = ( listStyleType == 'decimal' ? 0 : 1 );\n// }\n// if ( prop.querySelector('select[data-type=list-style-type]') ) {\n// prop.querySelector('select[data-type=list-style-type]').selectedIndex = (listStyleType == 'circle' ? 0 : (listStyleType == 'square' ? 1 : 2));\n// }\n// if ( prop.querySelector('select[data-type=list-alignment]') ) {\n// prop.querySelector('select[data-type=list-alignment]').selectedIndex = (textAlign == 'left' ? 0 : (textAlign == 'center' ? 1 : 2));\n// }\n// break;\n// case 'image':\n// break;\n// case 'button':\n// jQuery(prop).find('[data-type=button-color]').wpColorPicker({ defaultColor: node.style.backgroundColor });\n// break;\n//\n// }\n };\n\n if (element.kind == 'button') {\n //We must add this special kind of property, since it is triggered with click event\n var buttons = prop.getElementsByClassName('wptb-btn-size-btn');\n\n for (var i = 0; i < buttons.length; i++) {\n buttons[i].onclick = function () {\n var size = this.innerHTML,\n n_Class = this.dataset.element,\n infArr = n_Class.match(/wptb-options-(.+)-(\\d+)/i),\n type = infArr[1],\n num = infArr[2],\n affectedEl = document.getElementsByClassName('wptb-element-' + type + '-' + num)[0];\n affectedEl.classList.remove('wptb-size-S');\n affectedEl.classList.remove('wptb-size-M');\n affectedEl.classList.remove('wptb-size-L');\n affectedEl.classList.remove('wptb-size-XL');\n affectedEl.classList.add('wptb-size-' + size);\n var b = this.parentNode.getElementsByClassName('wptb-btn-size-btn');\n for (var i = 0; i < b.length; i++) {\n b[i].classList.remove('selected');\n }\n this.classList.add('selected');\n }\n }\n }\n\n var optionControls = prop.getElementsByClassName('wptb-element-property');\n\n for (var i = 0; i < optionControls.length; i++) {\n if (optionControls[i].classList.contains('wptb-color-picker')) {\n jQuery(optionControls[i]).wpColorPicker({\n change: function (event, ui) {\n var parent = event.target, classe, type, ps, number;\n classe = parent.dataset.element.match(/wptb-options-(.+)-(\\d+)/i);\n type = classe[1];\n number = classe[2];\n 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 = ui.color.toString();\n } else {\n affectedEl.getElementsByClassName('wptb-button')[0].style.backgroundColor = ui.color.toString();\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 = ui.color.toString();\n }\n }\n } else {\n affectedEl.style.color = ui.color.toString();\n }\n }\n });\n }\n\n if (optionControls[i].dataset.type === 'font-size') {\n var slider = optionControls[i].parentNode.parentNode.getElementsByClassName('wptb-text-font-size-slider')[0];\n slider.oninput = function () {\n this.parentNode.parentNode.getElementsByClassName('wptb-text-font-size-number')[0].value = this.value;\n this.parentNode.parentNode.getElementsByClassName('wptb-text-font-size-number')[0].onchange();\n }\n }\n\n if (optionControls[i].dataset.type === 'image-size') {\n var slider = optionControls[i].parentNode.parentNode.getElementsByClassName('wptb-image-size-slider')[0];\n slider.oninput = function () {\n this.parentNode.parentNode.getElementsByClassName('wptb-image-width-number')[0].value = this.value;\n this.parentNode.parentNode.getElementsByClassName('wptb-image-width-number')[0].onchange();\n }\n }\n\n optionControls[i].onchange = function (event) {\n\n var n_Class = this.dataset.element,\n infArr = n_Class.match(/wptb-options-(.+)-(\\d+)/i),\n type = infArr[1],\n num = infArr[2],\n affectedEl = document.getElementsByClassName('wptb-element-' + type + '-' + num)[0],\n val = this.value;\n\n switch (this.dataset.type) {\n case 'src':\n var img = affectedEl.getElementsByTagName(\"img\")[0];\n img.src = this.value;\n break;\n case 'alternative-text':\n var img = affectedEl.getElementsByTagName('img')[0];\n img.alt = this.value;\n break;\n case 'image-link':\n affectedEl.getElementsByTagName('a')[0].href = WPTB_Helper.linkHttpCheckChange( this.value );\n break;\n case 'image-link-target':\n if (this.checked == true) {\n affectedEl.getElementsByTagName('a')[0].target = '_blank';\n } else {\n affectedEl.getElementsByTagName('a')[0].target = '_self';\n }\n break;\n case 'image-link-nofollow':\n if (this.checked == true) {\n affectedEl.getElementsByTagName('a')[0].rel = 'nofollow';\n } else {\n affectedEl.getElementsByTagName('a')[0].removeAttribute('rel');\n }\n break;\n case 'image-size':\n affectedEl.getElementsByTagName('img')[0].style.width = this.value + '%';\n affectedEl.getElementsByTagName('img')[0].style.height = 'auto';\n this.parentNode.parentNode.getElementsByClassName('wptb-image-size-slider')[0].value = this.value;\n break;\n case 'image-alignment':\n affectedEl.getElementsByTagName( 'img' )[0].parentNode.style.textAlign = this.value;\n break;\n case 'font-size':\n affectedEl.style.fontSize = val + 'px';\n break;\n case 'button-alignment':\n var jc = '';\n if (this.value == 'left') {\n jc = 'start';\n } else if (this.value == 'right') {\n jc = 'flex-end';\n } else {\n jc = 'center';\n }\n affectedEl.getElementsByClassName('wptb-button-wrapper')[0].style.justifyContent = jc;\n break;\n case 'button-link':\n if ( this.value ) {\n affectedEl.getElementsByTagName( 'a' )[0].href = WPTB_Helper.linkHttpCheckChange( this.value );\n } else {\n affectedEl.getElementsByTagName( 'a' )[0].removeAttribute( 'href' );\n }\n break;\n case 'button-link-target':\n if (this.checked == true) {\n affectedEl.getElementsByTagName('a')[0].target = '_blank';\n } else {\n affectedEl.getElementsByTagName('a')[0].target = '_self';\n }\n break;\n case 'button-link-nofollow':\n if (this.checked == true) {\n affectedEl.getElementsByTagName('a')[0].rel = 'nofollow';\n } else {\n affectedEl.getElementsByTagName('a')[0].removeAttribute( 'rel' );\n }\n break;\n case 'button-id':\n if( this.value ) {\n affectedEl.getElementsByTagName( 'a' )[0].id = this.value;\n } else {\n affectedEl.getElementsByTagName( 'a' )[0].removeAttribute( 'id' );\n }\n case 'button-color':\n break;\n case 'list-alignment':\n let listItems = affectedEl.querySelectorAll('li');\n for (var i = 0; i < listItems.length; i++) {\n let p = listItems[i].querySelector( 'p' );\n if ( p ) {\n p.style.textAlign = this.value;\n }\n }\n break;\n case 'list-class':\n let parentNode = event.target\n .parentNode\n .parentNode\n .querySelector('[data-type=list-style-type]')\n .parentNode,\n parentNodeSettingItem = parentNode.parentNode;\n if (val == 'unordered') {\n parentNode.style.display = 'flex';\n \n parentNodeSettingItem.querySelector( '.wptb-list-icon-select-label' ).style.display = 'flex';\n let listItem = affectedEl.querySelectorAll('li');\n for (var i = 0; i < listItem.length; i++) {\n let p = listItem[i].querySelector( 'p' );\n p.removeAttribute ( 'class' );\n p.classList.add( 'wptb-list-style-type-disc' );\n }\n parentNodeSettingItem.querySelector('[data-type=list-style-type]').value = 'disc';\n } else {\n parentNode.style.display = 'none';\n parentNodeSettingItem.querySelector( '.wptb-list-icon-select-label' ).style.display = 'none';\n var listItem = affectedEl.querySelectorAll('li');\n for (var i = 0; i < listItem.length; i++) {\n let p = listItem[i].querySelector( 'p' );\n p.removeAttribute ( 'class' );\n }\n }\n break;\n case 'list-style-type':\n var listItem = affectedEl.querySelectorAll('li');\n for (var i = 0; i < listItem.length; i++) {\n let p = listItem[i].querySelector( 'p' );\n p.removeAttribute ( 'class' );\n p.classList.add( 'wptb-list-style-type-' + val.toLowerCase() );\n }\n break;\n }\n }\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 getDragImageCustom: function ( type ) {\n let hostName = location.protocol + '//' + location.hostname;\n let img = document.createElement( 'img' );\n img.src = hostName + '/wp-content/plugins/wp-table-builder/inc/admin/views/builder/icons/' + type + '.png';\n return img;\n },\n dragImagesArr: function() {\n return {\n text: WPTB_Helper.getDragImageCustom( 'text' ),\n image: WPTB_Helper.getDragImageCustom( 'image' ),\n button: WPTB_Helper.getDragImageCustom( 'button' ),\n list: WPTB_Helper.getDragImageCustom( 'list' )\n };\n },\n listItemsRecalculateIndex: function( ulElem ) {\n let par = ulElem.querySelectorAll( 'p' );\n if ( par.length > 0 ) {\n for ( let i = 0; i < par.length; i++ ) {\n par[i].dataset.listStyleTypeIndex = Number( i ) + 1 + '.';\n }\n }\n },\n listItemsTinyMceInit: function( listItem ) {\n tinyMCE.init({\n target: listItem,\n inline: true,\n plugins: \"link, paste\",\n dialog_type: \"modal\",\n theme: 'modern',\n menubar: false,\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\n paste_as_text: true,\n toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',\n setup: function(ed) {\n ed.on('keydown', function(e) {\n let article = e.target.parentNode;\n if ( e.keyCode == 13 ) {\n e.preventDefault();\n let text = e.target.innerHTML;\n let duplicate = new WPTB_ListItem( text, article, true );\n \n article.parentNode.insertBefore( duplicate.getDOMElement(), article );\n WPTB_Helper.listItemsTinyMceInit( duplicate.getDOMElement().firstChild );\n e.target.querySelector( 'p' ).innerText = 'New List Item';\n //tinyMCE.execCommand('mceInsertContent', false, 'New List Item');\n WPTB_Helper.listItemsRecalculateIndex( article.parentNode );\n \n } else if ( e.keyCode == '8' || e.keyCode == '46' ) {\n let p = e.target.querySelector( 'p' );\n let pText = p.innerHTML.replace(/<[^>]+>/g, '');\n pText = pText.replace( /\\s+/g, ' ' ).trim();\n pText = pText.replace( /&nbsp;/g, '').trim();\n \n if( pText == '' ) {\n e.preventDefault();\n e.target.querySelector( 'p' ).innerText = '\\n';\n } else {\n let selectedText = WPTB_Helper.getSelectionText();\n selectedText = selectedText.replace( /\\s+/g, ' ' ).trim();\n selectedText = selectedText.replace( /&nbsp;/g, '' ).trim();\n if( selectedText == pText ) {\n e.preventDefault();\n e.target.querySelector( 'p' ).innerText = '\\n';\n }\n }\n }\n });\n \n ed.on( 'keyup', function( e ) {\n \n });\n },\n init_instance_callback: function (editor) {\n window.currentEditor = editor;\n editor.on('focus', function (e) {\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\n if (window.currentEditor &&\n document.getElementById('wptb_builder').scrollTop >= 55 &&\n window.currentEditor.bodyElement.style.display != 'none') {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\n } else {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\n }\n });\n }\n });\n },\n buttonsTinyMceInit: function( target ) {\n tinyMCE.init({\n target: target,\n inline: true,\n plugins: \"link\",\n dialog_type: \"modal\",\n theme: 'modern',\n menubar: false,\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\n toolbar: 'bold italic strikethrough',\n setup : function(ed) {\n ed.on('keydown', function(e) {\n if (e.keyCode == 13) {\n e.preventDefault();\n }\n });\n },\n init_instance_callback: function (editor) {\n window.currentEditor = editor;\n editor.on('focus', function (e) {\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\n if (window.currentEditor &&\n document.getElementById('wptb_builder').scrollTop >= 55 &&\n window.currentEditor.bodyElement.style.display != 'none') {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\n } else {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\n }\n });\n }\n });\n },\n linkHttpCheckChange: function( link ) {\n if ( link ) {\n if ( link.indexOf( 'http://' ) == -1 && link.indexOf( 'https://' ) == -1 ) {\n let linkArr = link.split( '/' ),\n linkClean;\n if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {\n linkClean = linkArr[linkArr.length - 1];\n }\n return document.location.protocol + '//' + linkClean;\n } else { \n return link;\n }\n } else {\n return '';\n }\n },\n dataTitleColumnSet: function( table ) {\n let rows = table.rows,\n rowHead = rows[0];\n let computedStyleRowHead = getComputedStyle(rowHead);\n \n let rowHeadChildren = rowHead.children;\n let contentsForHeader = {};\n for( let i = 0; i < rowHeadChildren.length; i++ ) {\n let tdElements = rowHeadChildren[i].children;\n for( let j = 0; j < tdElements.length; j++ ) {\n let element = tdElements[j];\n if( element.classList.contains( 'wptb-ph-element' ) ) {\n let textContentStyle = element.getAttribute( 'style' );\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.titleColumn = contentsForHeader[thisRowChildren[j].dataset.xIndex][0];\n thisRowChildren[j].dataset.titleColumnFontSize = contentsForHeader[thisRowChildren[j].dataset.xIndex][1];\n thisRowChildren[j].dataset.titleColumnColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][2];\n thisRowChildren[j].dataset.titleBackgroundColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][3];\n thisRowChildren[j].dataset.titleAlign = contentsForHeader[thisRowChildren[j].dataset.xIndex][4];\n } else {\n thisRowChildren[j].dataset.titleColumn = '';\n thisRowChildren[j].dataset.titleColumnFontSize = '';\n thisRowChildren[j].dataset.titleColumnColor = '';\n thisRowChildren[j].dataset.titleBackgroundColor = '';\n thisRowChildren[j].dataset.titleAlign = '';\n }\n }\n }\n },\n findAncestor: function(el, cls) {\n while ((el = el.parentElement) && !el.classList.contains(cls));\n return el;\n },\n getSelectionText: function() {\n var txt = '';\n if (txt = window.getSelection) {\n txt = window.getSelection().toString();\n } else {\n txt = document.selection.createRange().text;\n }\n return txt;\n },\n settingsPanelClear: function() {\n document.getElementById( 'wptb-top-row-as-header' ).checked = false;\n document.getElementById( 'wptb-table-border-slider' ).value = 0;\n document.getElementById( 'wptb-table-border-number' ).value = 0;\n document.getElementById( 'wptb-inner-border-check' ).checked = false;\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\n document.getElementById( 'wptb-table-inner-border-slider' ).value = 1;\n document.getElementById( 'wptb-table-inner-border-number' ).value = 1;\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-border-color' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-header-bg' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-even-row-bg' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-odd-row-bg' );\n \n document.getElementById( 'wptb-table-cell-slider' ).value = 15;\n document.getElementById( 'wptb-table-cell-number' ).value = 15;\n },\n wpColorPickerClear: function( inputId ) {\n let input = document.getElementById( inputId );\n let wpPickerContainer = WPTB_Helper.findAncestor( input, 'wp-picker-container' );\n let parent = wpPickerContainer.parentNode;\n parent.removeChild( wpPickerContainer );\n let newInput = document.createElement( 'input' );\n newInput.setAttribute( 'id', inputId );\n newInput.value = \"\";\n parent.appendChild( newInput );\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}\n","var WPTB_Image = function ( src, DOMElementProt ) {\n let DOMElement,\n kindIndexProt = undefined,\n copy = false;\n if ( DOMElementProt == undefined ) {\n DOMElement = document.createElement('div');\n\t let anchor = document.createElement('a'),\n\t img = document.createElement('img');\n anchor.style.display = 'inline-block';\n anchor.appendChild(img);\n DOMElement.appendChild(anchor);\n \n anchor.onclick = function( e ) {\n e.preventDefault();\n }\n \n file_frame = wp.media.frames.file_frame = wp.media({\n\t\ttitle: 'Select a image to upload',\n\t\tbutton: {\n\t\t\ttext: 'Use this image'\n\t\t},\n\t\tmultiple: false\n });\n // When an image is selected, run a callback.\n file_frame.on('select', function () {\n attachment = file_frame.state().get('selection').first().toJSON();\n img.src = attachment.url;\n });\n // Finally, open the modal\n if (src == undefined) {\n file_frame.open();\n } else {\n img.src = src;\n }\n } else {\n DOMElement = DOMElementProt.cloneNode( true );\n \n DOMElement.getElementsByTagName( 'a' )[0].onclick = function(e) {\n e.preventDefault();\n };\n \n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n copy = true;\n };\n }\n \n this.kind = 'image';\n this.getDOMElement = function () {\n return DOMElement;\n };\n\tapplyGenericItemSettings( this, kindIndexProt, copy );\n\n\treturn this;\n};","var WPTB_Initializer = function () {\n\n const MIN_COLUMNS = 1,\n MIN_ROWS = 1,\n MAX_COLUMNS = 10,\n MAX_ROWS = 10;\n\n var tableGenerator = document.body;\n columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0],\n columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0],\n rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1],\n rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1],\n columnsInput = document.getElementById('wptb-columns-number'),\n rowsInput = document.getElementById('wptb-rows-number');\n \n columnsDecrementButton.onclick = function () {\n if (columnsInput.value > MIN_COLUMNS) {\n columnsInput.value--;\n }\n };\n\n columnsIncrementButton.onclick = function () {\n if (columnsInput.value < MAX_COLUMNS) {\n columnsInput.value++;\n }\n };\n\n rowsDecrementButton.onclick = function () {\n if (rowsInput.value > MIN_ROWS) {\n rowsInput.value--;\n }\n };\n\n rowsIncrementButton.onclick = function () {\n if (rowsInput.value < MAX_ROWS) {\n rowsInput.value++;\n }\n };\n\n document.getElementById('wptb-generate-table').onclick = function () {\n var columns = document.getElementById('wptb-columns-number').value,\n rows = document.getElementById('wptb-rows-number').value;\n\n WPTB_Table(columns, rows);\n }\n \n// if( document.getElementsByClassName( 'wptb-preview-table' ).length == 0 ) {\n// WPTB_LeftPanel();\n// }\n\n};\n","var WPTB_LeftPanel = function () {\n\n var table = document.getElementsByClassName('wptb-preview-table')[0],\n wptbElementButtons = document.getElementsByClassName('wptb-element');\n \n function wptbTdBgColorSavedSet( inputId, trNumber ) {\n if ( trNumber > 3 ) return;\n if( table ) {\n let tableRows = table.getElementsByTagName('tr');\n if ( tableRows.length > trNumber ) {\n let trBackgroundColor = tableRows[trNumber].style.backgroundColor;\n var wptbEvenRowBg = document.getElementById(inputId);\n if ( wptbEvenRowBg && trBackgroundColor ) {\n wptbEvenRowBg.value = WPTB_Helper.rgbToHex( trBackgroundColor );\n }\n }\n }\n \n }\n \n wptbTdBgColorSavedSet( 'wptb-even-row-bg', 1 );\n jQuery('#wptb-even-row-bg').wpColorPicker({\n change: function ( event, ui ) {\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 1; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = ui.color.toString();\n }\n },\n clear: function(){\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 1; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = '';\n let tds = tableRows[i].getElementsByTagName('td');\n for ( let j = 0; j < tds.length; j++ ) {\n tds[j].style.backgroundColor = '';\n }\n }\n },\n\n });\n \n wptbTdBgColorSavedSet( 'wptb-odd-row-bg', 2 );\n jQuery('#wptb-odd-row-bg').wpColorPicker({\n change: function ( event, ui ) {\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 2; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = ui.color.toString();\n }\n },\n clear: function(){\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 2; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = '';\n let tds = tableRows[i].getElementsByTagName( 'td' );\n for ( var j = 0; j < tds.length; j++ ) {\n tds[j].style.backgroundColor = '';\n }\n }\n },\n });\n \n wptbTdBgColorSavedSet( 'wptb-table-header-bg', 0 );\n jQuery('#wptb-table-header-bg').wpColorPicker({\n change: function (event, ui) {\n var tableHeader = table.getElementsByTagName('tr')[0];\n tableHeader.style.backgroundColor = ui.color.toString();\n },\n clear: function(){\n var tableHeader = table.getElementsByTagName('tr')[0];\n tableHeader.style.backgroundColor = '';\n let tds = tableHeader.getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n tds[j].style.backgroundColor = '';\n }\n },\n });\n \n function tableTopRowAsHeadSavedSet( table ) {\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n if( table && table.classList.contains( 'wptb-table-preview-head' ) ) {\n wptbTopRowAsHeader.checked = true;\n } else {\n wptbTopRowAsHeader.checked = false;\n }\n }\n tableTopRowAsHeadSavedSet( table );\n \n function tableBorderColorWidthSavedSet() {\n let table = document.getElementsByClassName('wptb-preview-table');\n if ( table.length > 0 ) {\n let tableBorderColor = table[0].style.borderColor;\n if ( tableBorderColor ) {\n let tableBorderColorInput = document.getElementById( 'wptb-table-border-color' );\n if ( tableBorderColorInput ) {\n tableBorderColorInput.value = WPTB_Helper.rgbToHex( tableBorderColor );\n }\n }\n \n let tableBorderWidth = table[0].style.borderWidth;\n if ( tableBorderWidth ) {\n let wptbTableBorderWidthSlider = document.getElementById('wptb-table-border-slider'),\n wptbTableBorderWidthNumber = document.getElementById('wptb-table-border-number');\n \n if ( wptbTableBorderWidthSlider ) {\n wptbTableBorderWidthSlider.value = parseInt( tableBorderWidth );\n }\n if ( wptbTableBorderWidthNumber ) {\n wptbTableBorderWidthNumber.value = parseInt( tableBorderWidth );\n }\n }\n \n \n let tableTd = table[0].querySelector( 'td' );\n let applyInnerBorder = tableTd.style.borderWidth;\n if ( applyInnerBorder ) {\n let innerBorderCheckInput = document.getElementById( 'wptb-inner-border-check' );\n let wptbApplyInnerBorder = document.getElementById( 'wptb-apply-inner-border' );\n if ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) {\n if ( innerBorderCheckInput ) {\n innerBorderCheckInput.checked = true;\n \n if ( wptbApplyInnerBorder ) {\n wptbApplyInnerBorder.classList.add( 'visible' );\n let wptbTableInnerBorderSlider = document.getElementById( 'wptb-table-inner-border-slider' );\n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\n wptbTableInnerBorderSlider.value = parseInt( applyInnerBorder );\n wptbTableInnerBorderNumber.value = parseInt( applyInnerBorder );\n }\n }\n } else {\n innerBorderCheckInput.checked = false;\n }\n }\n \n if ( ( tableBorderWidth && parseInt( tableBorderWidth ) > 0 ) || ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) ) {\n document.getElementById( 'wptb-table-border-color-set-area' ).style.display = '';\n }\n }\n }\n \n tableBorderColorWidthSavedSet();\n\n jQuery('#wptb-table-border-color').wpColorPicker({\n change: function (event, ui) {\n var tableCells = table.getElementsByTagName('td');\n table.style.border = document.querySelector('#wptb-table-border-number').value + 'px solid ' + ui.color.toString();\n\n for (var i = 0; i < tableCells.length; i++) {\n let tableInnerborderNumber = document.querySelector('#wptb-table-inner-border-number').value;\n if ( document.getElementById('wptb-inner-border-check').checked ) {\n tableCells[i].style.border = ( tableInnerborderNumber != 0 ? tableInnerborderNumber : 1 ) + 'px solid ' + ui.color.toString();\n }\n }\n },\n clear: function() {\n var tableCells = table.getElementsByTagName('td');\n table.style.borderColor = '';\n\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.borderColor = '';\n }\n }\n });\n\n function addInnerBorderSize(value) {\n var tableCells = table.getElementsByTagName('td');\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.borderWidth = document.querySelector('#wptb-table-inner-border-number').value + 'px';\n tableCells[i].style.borderStyle = 'solid';\n }\n }\n\n function addCellPadding(value) {\n var tableCells = table.getElementsByTagName('td');\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.padding = value + 'px';\n }\n }\n\n function addInnerBorder(checked) {\n var styles, color = document.querySelector('#wptb-table-border-color').value != undefined ?\n document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';\n if ( document.querySelector( '#wptb-table-inner-border-slider' ).value == 0 || document.querySelector( '#wptb-table-inner-border-number' ).value == 0 ) {\n document.querySelector( '#wptb-table-inner-border-slider' ).value = 1;\n document.querySelector( '#wptb-table-inner-border-number' ).value = 1;\n }\n let width = document.querySelector( '#wptb-table-inner-border-slider' ).value + 'px';\n let wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\n if( wptbPreviewTable.length > 0 ) {\n if (checked == 'checked') {\n document.getElementById('wptb-apply-inner-border').style.marginBottom = '0px';\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.border = width + ' solid ' + color;\n }\n document.getElementById( 'wptb-apply-inner-border' ).classList.add( 'visible' );\n } else {\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.border = '0px solid ' + color;\n }\n }\n }\n \n }\n\n function addBorderSize(value) {\n table.style.borderWidth = value + 'px';\n table.style.borderStyle = 'solid';\n }\n \n function cellPaddingSavedSet() {\n let table = document.getElementsByClassName('wptb-preview-table');\n \n if ( table.length > 0 ) {\n let td = table[0].querySelector( 'td' );\n \n if ( td ) {\n let padding = td.style.padding;\n \n if ( padding ) {\n let wptbTableCellSlider = document.getElementById('wptb-table-cell-slider'),\n wptbTableCellNumber = document.getElementById('wptb-table-cell-number');\n \n if ( wptbTableCellSlider ) {\n wptbTableCellSlider.value = parseInt( padding );\n }\n if ( wptbTableCellNumber ) {\n wptbTableCellNumber.value = parseInt( padding );\n }\n }\n }\n }\n }\n \n cellPaddingSavedSet();\n \n function numberImputSize( 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 thisValue = String( thisValue );\n if ( thisValue > maxValue ) {\n this.value = maxValue;\n }\n }\n }\n \n let wptbTableBorderNumber = document.getElementById( 'wptb-table-border-number' );\n numberImputSize( wptbTableBorderNumber, 1, 50 );\n \n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\n numberImputSize( wptbTableInnerBorderNumber, 1, 50 );\n \n let wptbTableCellNumber = document.getElementById( 'wptb-table-cell-number' );\n numberImputSize( wptbTableCellNumber, 1, 50 );\n \n let wptbTextfontSizeNumber = document.getElementById( 'wptb-text-font-size-number' );\n numberImputSize( wptbTextfontSizeNumber, 1, 50 );\n \n let wptbImageWidthNumber = document.getElementById( 'wptb-image-width-number' );\n numberImputSize( wptbImageWidthNumber, 2, 100 );\n \n \n \n document.getElementById('wptb-table-cell-slider').oninput = function () {\n document.getElementById('wptb-table-cell-number').value = this.value;\n addCellPadding(this.value);\n };\n\n document.getElementById('wptb-table-cell-number').onchange = function () {\n document.getElementById('wptb-table-cell-slider').value = this.value;\n addCellPadding(this.value);\n };\n\n document.getElementById('wptb-table-border-slider').oninput = function () {\n document.getElementById('wptb-table-border-number').value = this.value;\n addBorderSize(this.value);\n \n let wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\n if ( this.value == 0 && wptbInnerBorderCheck == false ) {\n tableBorderColorSetArea.style.display = 'none';\n } else {\n tableBorderColorSetArea.style.display = '';\n }\n };\n\n document.getElementById('wptb-table-border-number').onchange = function () {\n document.getElementById('wptb-table-border-slider').value = this.value;\n addBorderSize(this.value);\n };\n\n document.getElementById('wptb-table-inner-border-slider').oninput = function () {\n document.getElementById('wptb-table-inner-border-number').value = this.value;\n addInnerBorderSize(this.value);\n };\n\n document.getElementById('wptb-table-inner-border-number').onchange = function () {\n document.getElementById('wptb-table-inner-border-slider').value = this.value;\n addInnerBorderSize(this.value);\n };\n\n document.getElementById('wptb-inner-border-check').onchange = function () {\n if( table ) {\n let val = this.checked ? 'checked' : 'unchecked';\n addInnerBorder( val );\n let borderWidth = document.getElementById('wptb-table-border-slider').value,\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\n if( val == 'unchecked' && borderWidth == 0 ) {\n tableBorderColorSetArea.style.display = 'none';\n } else {\n tableBorderColorSetArea.style.display = '';\n }\n }\n \n };\n \n function createMobileHeadForTable( table, thisEvent ) {\n \n if( thisEvent.checked ) {\n WPTB_Helper.dataTitleColumnSet( table );\n \n table.classList.add( 'wptb-table-preview-head' );\n table.rows[0].classList.add( 'wptb-table-head' );\n } else {\n let rows = table.rows;\n table.classList.remove( 'wptb-table-preview-head' );\n rows[0].classList.remove( 'wptb-table-head' );\n \n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n thisRowChildren[j].removeAttribute( 'data-title-column' );\n }\n }\n }\n }\n \n document.getElementById( 'wptb-top-row-as-header' ).onchange = function () {\n createMobileHeadForTable( table, this );\n }\n\n for (var i = 0; i < wptbElementButtons.length; i++) {\n wptbElementButtons[i].ondragstart = function (e) {\n e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);\n e.dataTransfer.setData( 'wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement );\n }\n }\n \n if( table ) {\n document.getElementById('wptb-activate-cell-management-mode').onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-table-edit-mode-close' ).onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = table.toggleTableEditMode;\n document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;\n document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;\n document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;\n document.getElementById('wptb-add-row-after').onclick = table.addRowAfter;\n document.getElementById('wptb-add-end-column').onclick = table.addColumnEnd;\n document.getElementById('wptb-add-start-column').onclick = table.addColumnStart;\n document.getElementById('wptb-add-column-before').onclick = table.addColumnBefore;\n document.getElementById('wptb-add-column-after').onclick = table.addColumnAfter;\n document.getElementById('wptb-delete-column').onclick = table.deleteColumn;\n document.getElementById('wptb-delete-row').onclick = table.deleteRow;\n document.getElementById('wptb-merge-cells').onclick = table.mergeCells;\n document.getElementById('wptb-split-cell').onclick = table.splitCell;\n }\n \n document.querySelector( '.wptb-left-panel-extend' ).onclick = function() {\n let wptbContainer = document.querySelector( '.wptb-container' );\n if( wptbContainer ) {\n if ( wptbContainer.classList.contains( 'collapsed' ) ) {\n wptbContainer.classList.remove( 'collapsed' );\n } else {\n wptbContainer.classList.add( 'collapsed' );\n }\n }\n };\n \n // this code hides the \"element parameters\" area \n // when clicked outside this element and its \"tinymce\" toolbar \n let wptbBuilderPanel = document.getElementsByClassName( 'wptb-builder-panel' )[0];\n wptbBuilderPanel.addEventListener( 'click', 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 document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'table';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'block';\n document.getElementById( 'element-options-group' ).style.display = 'none';\n let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n if( wpcdFixedToolbar.hasAttribute( 'data-toolbar-active-id' ) ) {\n document.getElementById( wpcdFixedToolbar.getAttribute( 'data-toolbar-active-id' ) ).classList.remove( 'toolbar-active' );\n }\n } \n }, false);\n \n};","var WPTB_List = function ( innerElements, DOMElementProt ) {\n\n var el_L = document.createElement('ul'), item,\n DOMElement = document.createElement('div'),\n kindIndexProt = undefined,\n copy = false;\n DOMElement.classList.add( 'wptb-list-item-container' );\n\n this.kind = 'list';\n\n if (innerElements === '') {\n //Case for edit mode list\n } else if ( !innerElements ) {\n for (var i = 0; i < 3; i++) {\n item = new WPTB_ListItem( '<p>List Item ' + (i + 1) + '</p>');\n el_L.appendChild(item.getDOMElement());\n }\n } else {\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n copy = true;\n };\n \n for ( var i = 0; i < innerElements.length; i++ ) {\n let listItem = DOMElementProt.querySelector( 'li' );\n item = new WPTB_ListItem( innerElements[i], listItem, true );\n el_L.appendChild(item.getDOMElement());\n }\n }\n DOMElement.appendChild(el_L);\n //window.addElementOptions('list', elList);\n\n this.getDOMElement = function () {\n return DOMElement;\n }\n applyGenericItemSettings( this, kindIndexProt, copy );\n WPTB_Helper.listItemsRecalculateIndex( el_L );\n\n return this;\n};","var WPTB_ListItem = function ( text, DOMElementProt, copy ) {\n let wptbListItemReturn;\n if ( DOMElementProt == undefined || ( DOMElementProt && copy )) {\n if (text == undefined) text = 'New List Item';\n var DOMElement = document.createElement('li'),\n //divdot = document.createElement('div'),\n divcontent = document.createElement('div');\n //libullet = document.createElement('li');\n //divdot.classList.add('wptb-list-item-style-dot');\n divcontent.classList.add('wptb-list-item-content');\n //libullet.classList.add('wptb-bullet');\n if ( DOMElementProt ) {\n let styleDot = DOMElementProt.getAttribute( 'style' );\n if ( styleDot ) {\n DOMElement.setAttribute( 'style', styleDot );\n }\n }\n //DOMElement.appendChild(divdot);\n DOMElement.appendChild(divcontent);\n //divdot.appendChild(libullet);\n divcontent.innerHTML = text;\n divcontent.onkeyup = window.listItemKeyListener;\n \n wptbListItemReturn = true;\n } else {\n var DOMElement = DOMElementProt;\n var divcontent = DOMElement.getElementsByClassName( 'wptb-list-item-content' )[0];\n \n divcontent.onkeyup = window.listItemKeyListener;\n \n wptbListItemReturn = false;\n }\n \n DOMElement.onmouseenter = function (event) {\n\n var btnDelete = document.createElement('span'),\n btnCopy = document.createElement('span'),\n actions = document.createElement('span'),\n previous,\n i;\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 this.classList.add('wptb-directlyhovered');\n\n btnDelete.onclick = function () {\n var action = this.parentNode, \n item = this.parentNode.parentNode,\n parent = item.parentNode;\n item.removeChild( action );\n parent.removeChild( item );\n WPTB_Helper.listItemsRecalculateIndex( parent );\n };\n\n btnCopy.onclick = function (event) {\n var listItem = event.target.parentNode.parentNode,\n content = listItem.querySelector('.wptb-list-item-content'),\n html = content.innerHTML;\n var duplicate = new WPTB_ListItem( html, listItem, true );\n listItem.parentNode.insertBefore( duplicate.getDOMElement(), DOMElement );\n WPTB_Helper.listItemsTinyMceInit( duplicate.getDOMElement().firstChild );\n setTimeout( function(){\n divcontent.innerHTML = html;\n WPTB_Helper.listItemsRecalculateIndex( listItem.parentNode );\n }, 5 );\n };\n\n actions.append(btnCopy, btnDelete);\n this.appendChild(actions);\n };\n\n DOMElement.onmouseleave = function (event) {\n this.removeAttribute( 'class' );\n let iter = 0;\n while( event.target.querySelector( '.wptb-actions' ) && iter < 5 ) {\n event.target.querySelector( '.wptb-actions' ).remove();\n iter++;\n }\n };\n\n this.getDOMElement = function () {\n return DOMElement;\n };\n \n if ( wptbListItemReturn ) {\n return this;\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}","var WPTB_Parser2 = function (code) {\n if( Array.isArray( code ) ) {\n let elementHtml;\n \n if ( code.length == 1) {\n return elementHtml.appendChild( document.createTextNode( code[0] ) );\n }\n if( 0 in code ) {\n let tagName = code[0];\n elementHtml = document.createElement( tagName );\n \n if ( 1 in code ) {\n if( Array.isArray( code[1] ) ) {\n let attributes = code[1];\n \n for( let i = 0; i < attributes.length; i++ ) {\n if( Array.isArray( attributes[i] ) ) {\n elementHtml.setAttribute(attributes[i][0], attributes[i][1]);\n }\n }\n }\n }\n \n if ( 2 in code ) {\n if ( Array.isArray( code[2] ) ) {\n for ( let i = 0; i < code[2].length; i++ ) {\n if ( typeof code[2][i] === 'string' && tagName.toLowerCase() == 'p' ) {\n elementHtml.appendChild( document.createTextNode( code[2][i] ) );\n continue;\n }\n if ( ! WPTB_Parser( code[2][i] ) ) continue;\n elementHtml.appendChild( WPTB_Parser( code[2][i] ) );\n }\n } else if( typeof code[2] === 'string' ) {\n elementHtml.appendChild( document.createTextNode( code[2] ) );\n }\n \n }\n }\n \n return elementHtml;\n } else {\n return false;\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 let wptbDropHandle = document.querySelector( '.wptb-drop-handle' ),\n wptbDropBorderMarker = document.querySelector( '.wptb-drop-border-marker' );\n if ( wptbDropHandle || wptbDropBorderMarker ) {\n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n }\n }\n };\n \n let shortcodePopupWindow = document.getElementsByClassName( 'wptb-shortcode-popup-window-modal' )[0];\n document.getElementsByClassName( 'wptb-embed-btn' )[0].onclick = function () {\n if( ! this.classList.contains( 'wptb-embed-disable' ) ) {\n shortcodePopupWindow.classList.add( 'wptb-shortcode-popup-show' );\n }\n }\n \n document.getElementsByClassName( 'wptb-shortcode-popup-dark-area' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-shortcode-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-shortcode-popup-window-close-icon' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-shortcode-popup-show' );\n }\n\n document.getElementsByClassName( 'wptb-save-btn' )[0].onclick = function () {\n let bar = document.querySelector( '.wptb-edit-bar' );\n if ( bar && bar.classList.contains( 'visible' ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' )[0];\n table.toggleTableEditMode();\n }\n\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=save_table\",\n t = document.getElementById( 'wptb-setup-name' ).value.trim(),\n messagingArea,\n code = document.getElementsByClassName( 'wptb-preview-table' );\n if( code.length > 0 ) {\n code = WPTB_Stringifier( code[0] );\n code = code.outerHTML;\n } else { \n code = '';\n }\n \n 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 security_code: wptb_admin_object.security_code\n };\n if (( rs = WPTB_Helper.detectMode() ) || ( rs = document.wptbId )) {\n params.id = rs;\n }\n params = JSON.stringify( params );\n\n http.open('POST', url, true);\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function (action) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n\n if ( data[0] == 'saved' ) {\n document.wptbId = data[1];\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully saved.</div>';\n document.getElementsByClassName( 'wptb-embed-btn' )[0].classList.remove( 'wptb-embed-disable' );\n document.getElementById( 'wptb-embed-shortcode' ).value = '[wptb id=' + data[1] + ']';\n } else if( data[0] == 'edited' ) {\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully updated.</div>';\n } else {\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Safety problems</div>';\n }\n messagingArea.classList.add( 'wptb-success' );\n setTimeout( function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n }\n }\n http.send( params );\n }\n};\n","var WPTB_Space = function ( elSpaceBetween ) {\n\n function newElementProxy(el) {\n if (el.includes('list')) {\n return new WPTB_List();\n } else if (el.includes('image')) {\n return new WPTB_Image();\n } else if (el.includes('text')) {\n return new WPTB_Text();\n } else if (el.includes('button')) {\n return new WPTB_Button();\n }\n }\n let spaceBetween;\n if ( ! elSpaceBetween ) {\n spaceBetween = document.createElement('div'), spaceBetween.classList.add('wptb-space-between');\n } else {\n spaceBetween = elSpaceBetween;\n }\n\n spaceBetween.ondragenter = function () {\n this.classList.add('visible');\n };\n spaceBetween.ondragover = function (event) {\n event.preventDefault();\n };\n\n spaceBetween.ondragleave = function () {\n this.classList.remove('visible');\n };\n\n spaceBetween.ondrop = function (event) {\n event.stopPropagation();\n\n var p = event.target.nextSibling,\n td = event.target,\n element, t_space, spaceParent;\n\n while ( !td.classList.contains('wptb-droppable') ) {\n td = td.parentNode;\n }\n\n if (event.dataTransfer.getData('wptbElement')) {\n element = newElementProxy(event.dataTransfer.getData('wptbElement'));\n this.classList.remove('visible');\n\n if (p == null) {\n td.appendChild(element.getDOMElement());\n td.appendChild(new WPTB_Space());\n } else {\n td.insertBefore(element.getDOMElement(), p);\n td.insertBefore(new WPTB_Space(), p);\n }\n\n } else {\n alert(event.dataTransfer.getData('node'));\n element = document.getElementsByClassName(event.dataTransfer.getData('node'))[0];\n t_space = element.nextSibling;\n spaceParent = element.parentNode;\n if (t_space != undefined) {\n spaceParent.removeChild(t_space);\n }\n\n if (p == null) {\n td.appendChild(element);\n td.appendChild(new WPTB_Space());\n } else {\n td.insertBefore(element, p);\n td.insertBefore(new WPTB_Space(), p);\n }\n\n }\n this.classList.remove('visible');\n };\n \n if ( ! elSpaceBetween ) {\n return spaceBetween;\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.dataset.reconstraction = 1;\n \n let tds = code.getElementsByTagName( 'td' );\n if ( tds.length > 0 ) {\n for ( let i = 0; i < tds.length; i++ ) {\n \n for( let i = 0; i < tds.length; i++ ) {\n if( code.dataset.reconstraction == 1 && tds[i].colSpan > 1 || tds[i].rowSpan > 1 ) {\n code.dataset.reconstraction = 0;\n break;\n }\n }\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 innerElements[j].classList.remove( 'wptb-directlyhovered' );\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 wptbActions[0].parentNode.removeChild( wptbActions[0] );\n wptbActionsLength--;\n } \n }\n }\n \n if( tds[i].hasAttribute( 'data-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.titleColumn = tds[i].dataset.titleColumn;\n columnNameDiv.setAttribute( 'style', 'font-size:' + tds[i].dataset.titleColumnFontSize + '; \\n\\\n color:' + tds[i].dataset.titleColumnColor + '; background-color:' + tds[i].dataset.titleBackgroundColor + '; text-align:' + tds[i].dataset.titleAlign + ';' );\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 WPTB_Stringifier2 = function ( node, start = false ) {\n\n\tif ( node == undefined ) {\n\t\treturn '';\n\t} else if ( node.tagName == undefined && node.nodeType == 3 ) {\n return node.nodeValue;\n }\n \n let code = [],\n children,\n int_elem_arr = false,\n attributes = [...node.attributes],\n attributes_list = [],\n internal_elements = [];\n if ( ( node.parentNode.classList.contains( 'wptb-list-item-content' ) || \n node.parentNode.classList.contains( 'mce-content-body' ) ) && \n node.tagName.toLowerCase() == 'p' ) {\n children = node.childNodes;\n int_elem_arr = true;\n } else if( node.children.length > 0 ) {\n children = node.children;\n } else {\n children = node.childNodes;\n }\n if ( attributes.length > 0 ) {\n for ( let i = 0; i < attributes.length; i++ ) {\n attributes_list[i] = [attributes[i].name, attributes[i].value];\n }\n } else {\n attributes_list = '';\n }\n \n if ( children.length > 0 ) {\n for ( let i = 0; i < children.length; i++) {\n let inter_elem = WPTB_Stringifier(children[i]);\n \n if ( Array.isArray( inter_elem ) || int_elem_arr ) {\n internal_elements[i] = inter_elem;\n } else if ( typeof inter_elem === 'string' && inter_elem ) {\n internal_elements = inter_elem;\n }\n }\n } else {\n internal_elements = '';\n }\n \n \n code.push(node.tagName.toLowerCase(), attributes_list , internal_elements);\n \n return code;\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 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 } 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 } 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 }\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 tds = table.getElementsByClassName('wptb-highlighted');\n while (tds.length) {\n tds[0].classList.remove('wptb-highlighted');\n }\n for (var i = 0; i < array.length; i++) {\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = 0;\n }\n }\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n };\n\n /*\n * This fills the abstract representation of our table with \n * zeros, at the start. the max amount of cells is the greatest sum\n * of all colspans for row.\n */\n\n var fillTableArray = function () {\n var colspansSums = [], a = [];\n\n //calculate max amount of cells inside a row\n for (var i = 0; i < table.rows.length; i++) {\n var cells = table.rows[i].getElementsByTagName('td'),\n colspanSumInRow = 0;\n for (var j = 0; j < cells.length; j++) {\n colspanSumInRow += cells[j].colSpan;\n }\n colspansSums.push(colspanSumInRow);\n }\n\n maxAmountOfCells = Math.max.apply(null, colspansSums);\n //calculate max rows\n var maxAmountOfRows = table.rows.length;\n\n // fill with zeros from both values\n for (var i = 0; i < maxAmountOfRows; i++) {\n a[i] = [];\n for (var j = 0; j < maxAmountOfCells; j++) {\n a[i].push(0);\n }\n }\n drawTable(a);\n return a;\n };\n\n /*\n * This function gets the sum of all colspans in a row.\n * @param number the number of row to be used as reference.\n */\n var getActualPointsInRow = function (row) {\n var tds = table.rows[row].getElementsByTagName('td'),\n points = 0;\n for (var i = 0; i < tds.length; i++) {\n points += tds[i].colSpan;\n }\n return points;\n }\n\n /*\n * This function gets us the exact coordinates of\n * an exact cell, in a more reliable way than xIndex and yIndex,\n * these last ones were meant to be used for getting the cell trough them.\n * @param DOMElement the cell to get the coordinates.\n */\n var getCoords = function (search) {\n var skipInCols = [], cell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n skipInCols[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (skipInCols[xPosition]) {\n skipInCols[xPosition]--;\n } else {\n var td = cellsBuffer[cellPointer++];\n if (td == search) {\n return [i, xPosition];\n }\n if (td.rowSpan > 1) {\n for ( let k = 0; k < td.colSpan; k++ ) {\n skipInCols[xPosition + k] = td.rowSpan - 1;\n }\n stepsToMove = td.colSpan;\n } else if (td.colSpan > 1) {\n stepsToMove = td.colSpan;\n }\n }\n }\n }\n };\n\n jQuery('#wptb-table-header-bg').val('');\n jQuery('#wptb-even-row-bg').val('');\n jQuery('#wptb-odd-row-bg').val('');\n jQuery('#wptb-table-border-color').val('');\n jQuery('#wptb-table-inner-border-number,#wptb-table-inner-border-slider').val('0');\n jQuery('#wptb-table-border-number,#wptb-table-border-slider').val('0');\n jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');\n\n if (columns || rows) {\n //END OF PRIVATE FUNCTIONS\n for (var i = 0; i < settings.length; i++) {\n if (settings[i].id !== 'wptb-apply-inner-border') {\n settings[i].classList.add('visible');\n }\n }\n\n //Create a HTML Table element.\n table = document.createElement('table');\n table.classList.add('wptb-preview-table');\n\n //Add the data rows.\n for (var i = 0; i < rows; i++) {\n\n row = table.insertRow(-1);\n row.classList.add( 'wptb-row' );\n\n for (var j = 0; j < columns; j++) {\n cell = new WPTB_Cell(mark);\n cell.setCoords(i, j);\n row.appendChild(cell.getDOMElement());\n }\n }\n } else {\n let wptb_preview_table = document.getElementsByClassName( 'wptb-preview-table' );\n\n if (wptb_preview_table.length > 0) {\n table = wptb_preview_table[0];\n\n let cells = table.getElementsByTagName('td');\n\n if (cells.length > 0) {\n for (let i = 0; i < cells.length; i++) {\n WPTB_Cell(mark, cells[i]);\n }\n }\n }\n }\n\n /*\n * This just toggles visibility of cell edit bar, and toggles \n * cell selecting mode.\n */\n\n table.toggleTableEditMode = function () {\n let bar = document.getElementsByClassName('wptb-edit-bar'),\n cellModeBackground = document.getElementById('wptb-cell_mode_background'),\n leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),\n 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 wptbPreviewTable.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.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,\n tdsArr = [];\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n for (var i = 0; i < trs.length; i++) {\n if ( i == 0 ) {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-table-header-bg').val();\n }\n if( wptbTopRowAsHeader.checked ) {\n if( start == undefined ) {\n this.classList.add( 'wptb-table-preview-head' ); \n trs[i].classList.add( 'wptb-table-head' )\n } ;\n } else {\n if( start == undefined ) {\n this.classList.remove( 'wptb-table-preview-head' );\n trs[i].classList.remove( 'wptb-table-head' );\n }\n }\n } else {\n if (i % 2 == 0) {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-odd-row-bg').val();\n }\n trs[i].classList.remove( 'wptb-table-head' );\n } else {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-even-row-bg').val();\n }\n trs[i].classList.remove( 'wptb-table-head' );\n }\n }\n\n tdsArr[i];\n tds = trs[i].getElementsByTagName('td');\n\n if (tdsArr[i] == undefined) {\n tdsArr[i] = [];\n }\n\n let jMainIter = 0;\n for (var j = 0; j < tds.length; j++) {\n if (tdsArr[i][j] != undefined) {\n for (let y = 0; y < 100; y++) {\n if (tdsArr[i][jMainIter] != undefined) {\n jMainIter++;\n continue;\n }\n tdsArr[i][jMainIter] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n break;\n }\n } else {\n tdsArr[i][j] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n }\n tds[j].dataset.yIndex = i;\n\n if (tds[j].colSpan > 1) {\n for (let k = 1; k < tds[j].colSpan; k++) {\n jMainIter++;\n tdsArr[i][jMainIter] = 'tdDummy';\n }\n }\n\n if (tds[j].rowSpan > 1) {\n for (let x = 1; x < tds[j].rowSpan; x++) {\n if (tdsArr[i + x] == undefined) {\n tdsArr[i + x] = [];\n }\n for (let z = 0; z < tds[j].colSpan; z++) {\n tdsArr[i + x][jMainIter - tds[j].colSpan + 1 + z ] = 'tdDummy';\n }\n }\n }\n jMainIter++;\n }\n if (j > maxCols) {\n maxCols = j;\n }\n }\n this.columns = maxCols;\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 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 }\n table.rows[i].appendChild(td.getDOMElement());\n array[i].push(0);\n }\n maxAmountOfCells++;\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 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 }\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 WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 }\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 WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 currentTableTd,\n currentTdStyle;\n r.classList.add( 'wptb-row' );\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 < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n }\n r.appendChild(td.getDOMElement());\n }\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 currentTableTd = currentTable[0].querySelector('td');\n }\n\n if (currentTableTd) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n }\n r.appendChild(td.getDOMElement());\n }\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 r.appendChild( td.getDOMElement() );\n }\n\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\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 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 WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n };\n\n /*\n * Searches for rowspanned cells up to row number meeting it.\n * @param number the number of row where the function\n * must search up to.\n */\n\n table.findRowspannedCells = function (row) {\n var array = [],\n difference;\n actualPoints = getActualPointsInRow(row);\n if (actualPoints === maxAmountOfCells) {\n return [];\n }\n difference = maxAmountOfCells - actualPoints;\n\n for (var i = row - 1; i >= 0 && difference; i--) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n if (tds[i].rowSpan > 1) {\n array.push(tds[i]);\n difference -= tds[i].colSpan;\n }\n }\n }\n return array;\n\n }\n\n /*\n * This function explores the table and adds \n * a cell for each lacking one for each row\n * to meet an even amount of cells.\n */\n\n table.addLackingCells = function () {\n var sumRows = [];\n for (var i = 0; i < table.rows.length; i++) {\n sumRows.push(0);\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n if (tds[j].rowSpan > 1) {\n for (var k = 1; k < tds[j].rowSpan; k++) {\n sumRows[i + k]++;\n }\n }\n }\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td'),\n totalColspan = 0;\n for (var j = 0; j < tds.length; j++) {\n totalColspan += tds[j].colSpan;\n }\n totalColspan += sumRows[i];\n difference = maxAmountOfCells - totalColspan;\n for (var j = 0; j < difference; j++) {\n var td = new WPTB_Cell(mark);\n table.rows[i].appendChild(td.getDOMElement());\n //table.rows[i].insertBefore( td.getDOMElement(), rows[i].nextSibling );\n }\n }\n };\n\n /*\n * This function deletes the row of currently\n * selected cell. \n */\n\n table.deleteRow = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyles = cell.getAttribute('style'),\n rowspan = cell.rowSpan,\n row = getCoords(cell)[0],\n thisRow,\n aux;\n \n if ( rowspan == undefined ) rowspan = 1;\n \n for ( let i = 0; i < rowspan; i++ ) {\n thisRow = table.rows[row];\n let thisRowChildren = thisRow.children,\n nextRow = table.rows[row + 1],\n nextRowChildren,\n nextRowChildrenLength,\n tdArr = [];\n\n if( nextRow != undefined ) {\n nextRowChildren = nextRow.children;\n nextRowChildrenLength = nextRowChildren.length;\n for (let j = 0; j < thisRowChildren.length; j++) {\n if ( thisRowChildren[j].rowSpan > 1 ) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().colSpan = thisRowChildren[j].colSpan;\n td.getDOMElement().rowSpan = thisRowChildren[j].rowSpan - 1;\n\n let nextRowChildrenK = undefined;\n for ( let k = 0; k < nextRowChildrenLength; k++ ) {\n if ( Number( nextRowChildren[k].dataset.xIndex ) > Number( thisRowChildren[j].dataset.xIndex ) ) {\n nextRowChildrenK = nextRowChildren[k];\n break;\n } \n }\n\n if ( nextRowChildrenK ) {\n tdArr.push( [td, nextRowChildrenK] );\n } else {\n tdArr.push( [td] );\n }\n }\n }\n\n if ( tdArr.length > 0 ) {\n for ( let k = 0; k < tdArr.length; k++ ) {\n if ( tdArr[k][1] != undefined ) {\n nextRow.insertBefore( tdArr[k][0].getDOMElement(), tdArr[k][1] );\n } else {\n nextRow.appendChild( tdArr[k][0].getDOMElement() );\n }\n }\n }\n }\n \n let tableRows = table.rows;\n if ( tableRows.length > 0 ) {\n for ( let j = 0; j < row; j++ ) {\n let jRowChildren = tableRows[j].children;\n if ( jRowChildren.length > 0 ) {\n for ( let x = 0; x < jRowChildren.length; x++ ) {\n if ( jRowChildren[x].rowSpan - 1 >= row - j ) {\n jRowChildren[x].rowSpan--;\n }\n }\n }\n }\n }\n aux = Array.from(array[0]);\n array.pop(aux);\n drawTable(array);\n table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);\n \n if( table.rows.length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n WPTB_Helper.settingsPanelClear();\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n undoSelect();\n }\n\n /*\n * This function deletes the column of currently\n * selected cell. Again, this is way more complicated than\n * delete row case.\n */\n\n table.deleteColumn = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellXIndex = cell.dataset.xIndex,\n colspan = cell.colSpan;\n \n for ( let i = 0; i < colspan; i++ ) {\n for ( let j = 0; j < table.rows.length; j++ ) {\n let rowChildren = table.rows[j].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for ( let k = rowChildrenLength - 1; k >= 0; k-- ) {\n if ( Number( rowChildren[k].dataset.xIndex ) == Number( cellXIndex ) ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n } else {\n table.rows[j].removeChild( rowChildren[k] );\n }\n break;\n } else if( Number( rowChildren[k].dataset.xIndex ) < Number( cellXIndex ) && \n Number( rowChildren[k].dataset.xIndex ) + \n Number( rowChildren[k].colSpan -1 ) >= cellXIndex ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n }\n break;\n }\n }\n }\n }\n \n for ( let j = 0; j < table.rows.length; j++ ) {\n if (array[j] != undefined)\n array[j].pop();\n }\n \n maxAmountOfCells--;\n \n if( table.querySelectorAll( 'td' ).length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n WPTB_Helper.settingsPanelClear();\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n undoSelect();\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\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_Text = function ( text , DOMElementProt ) {\n let DOMElement = document.createElement('div'),\n elText2 = document.createElement('div'),\n elP = document.createElement('p'),\n kindIndexProt = undefined,\n copy = false;\n \n DOMElement.classList.add( 'wptb-text-container' );\n\n elP.innerHTML = text != undefined ? text : 'Text';\n elText2.appendChild(elP);\n DOMElement.appendChild(elText2);\n if ( DOMElementProt ) {\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n copy = true;\n };\n\n let attributes = [...DOMElementProt.attributes];\n for( let i = 0; i < attributes.length; i++ ) {\n DOMElement.setAttribute(attributes[i].name, attributes[i].value);\n }\n } \n\n this.kind = 'text';\n this.getDOMElement = function () {\n return DOMElement;\n };\n applyGenericItemSettings( this, kindIndexProt, copy );\n\n return this;\n};","var WPTB_innerElementSet = function ( element ) {\n \n function newElementProxy(el) {\n if (el == 'list') {\n return new WPTB_List();\n } else if (el == 'image') {\n return new WPTB_Image();\n } else if (el == 'text') {\n return new WPTB_Text();\n } else if (el == 'button') {\n return new WPTB_Button();\n }\n }\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 = 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 == 'Abowe Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n let thisRow = td.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n } else {\n return;\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n\n WPTB_innerElementSet( element );\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 listItems,\n copy;\n \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 } else if ( kindIndexProt && ! copy ) {\n index = kindIndexProt.split('-')[1];\n }\n \n node.onmouseenter = function (event) {\n this.classList.add('wptb-directlyhovered');\n let btnDelete = document.createElement( 'span' ),\n btnCopy = document.createElement( 'span' ),\n btnMove = document.createElement( 'span' ),\n actions = document.createElement( 'span' ), i;\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 btnMove.classList.add(\"dashicons\", \"dashicons-move\", 'wptb-move-action');\n btnMove.draggable = true;\n btnDelete.onclick = function (event) {\n let act = this.parentNode.parentNode,\n el = act.parentNode;\n el.removeChild(act);\n \n if( act.kind == 'text' ) {\n let thisRow = el.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n };\n btnCopy.onclick = function (event) {\n let copy;\n if (element.kind == 'list') {\n var td = event.target.parentNode.parentNode.parentNode,\n temp = [],\n srcList = event.target.parentNode.parentNode.querySelectorAll('ul li .wptb-list-item-content');\n\n for (var i = 0; i < srcList.length; i++) {\n temp.push(srcList[i].innerHTML);\n }\n\n copy = new WPTB_List( temp, node );\n\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\n } else if (element.kind == 'text') {\n var td = event.target.parentNode.parentNode.parentNode;\n copy = new WPTB_Text(event.target.parentNode.parentNode.childNodes[0].innerHTML, node);\n\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\n } else if ( element.kind == 'image' ) {\n var td = event.target.parentNode.parentNode.parentNode;\n copy = new WPTB_Image( event.target.parentNode.parentNode.children[0].children[0].src, node );\n\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\n } else {\n var td = event.target.parentNode.parentNode.parentNode,\n text = event.target.parentNode.parentNode.childNodes[0].querySelector( 'p' ).innerHTML;\n copy = new WPTB_Button( text, node );\n\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\n }\n \n WPTB_innerElementSet( copy.getDOMElement() );\n };\n let parent = this,\n infArr,\n type;\n infArr = parent.className.match(/wptb-element-(.+)-(\\d+)/i);\n type = infArr[1];\n let dragImagesArr = WPTB_Helper.dragImagesArr();\n btnMove.ondragstart = function (event) {\n this.parentNode.style.opacity = 0;\n parent.classList.remove( 'wptb-directlyhovered' );\n parent.classList.add( 'wptb-moving-mode' );\n \n event.dataTransfer.setDragImage( dragImagesArr[type], 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.parentNode;\n if( act.kind == 'text' ) {\n let thisRow = el.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n };\n\n if (element.kind === 'button') {\n let a = node.querySelector( 'a' ),\n target = a.querySelector( 'div' );\n a.onclick = function( e ) {\n e.preventDefault();\n }\n WPTB_Helper.buttonsTinyMceInit( target );\n } else if (element.kind === 'text') {\n tinyMCE.init({\n target: node.childNodes[0],\n inline: true,\n plugins: \"link, paste\",\n dialog_type: \"modal\",\n theme: 'modern',\n menubar: false,\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\n paste_as_text: true,\n toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',\n setup : function( ed ) {\n ed.on( 'change', function(e) {\n let row = WPTB_Helper.findAncestor( node, 'wptb-row' );\n if( row.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n });\n },\n init_instance_callback: function (editor) {\n window.currentEditor = editor;\n //editor.fire('focus');\n editor.on('focus', function (e) {\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\n if (window.currentEditor &&\n document.getElementById('wptb_builder').scrollTop >= 55 &&\n window.currentEditor.bodyElement.style.display != 'none') {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\n } else {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\n }\n });\n }\n });\n \n } else {\n listItems = node.getElementsByClassName( 'wptb-list-item-content' );\n for ( let i = 0; i < listItems.length; i++ ) {\n WPTB_Helper.listItemsTinyMceInit( listItems[i] );\n }\n }\n\n actions.appendChild(btnMove);\n actions.appendChild(btnCopy);\n actions.appendChild(btnDelete);\n this.appendChild( actions );\n };\n\n node.onmouseleave = function ( event ) {\n this.classList.remove( 'wptb-directlyhovered' );\n let iter = 0;\n while( event.target.querySelector( '.wptb-actions' ) && iter < 5 ) {\n event.target.querySelector( '.wptb-actions' ).remove();\n iter++;\n }\n };\n \n // Change data-title-column if the title was changed\n if( element.kind == 'text' ) {\n var observer = new MutationObserver( function( mutations ) {\n let row = WPTB_Helper.findAncestor( node, 'wptb-row' );\n if( row.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n });\n var config = { attributes: true, attributeFilter: ['style'] };\n observer.observe( element.getDOMElement(), config );\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\n document.counter.increment(element.kind);\n};",""]}
1
+ {"version":3,"sources":["applyGenericItemSettings.js","wptb-builder.js","WPTB_Builder.js","WPTB_Button.js","WPTB_Cell.js","WPTB_DropHandle.js","WPTB_ElementCounters.js","WPTB_ElementOptions.js","WPTB_Helper.js","WPTB_Image.js","WPTB_Initializer.js","WPTB_innerElementSet.js","WPTB_LeftPanel.js","WPTB_List.js","WPTB_ListItem.js","WPTB_MultipleSelect.js","WPTB_Parser.js","WPTB_Parser2.js","WPTB_Settings.js","WPTB_Space.js","WPTB_Stringifier.js","WPTB_Stringifier2.js","WPTB_Table.js","WPTB_Text.js"],"names":["applyGenericItemSettings","element","kindIndexProt","copy","node","getDOMElement","index","listItems","undefined","document","counter","nextIndex","kind","wptbElements","getElementsByClassName","elementIndexesArr","i","length","regex","RegExp","infArr","className","match","push","elementIndexMax","Math","max","split","onmouseenter","event","classList","add","btnDelete","createElement","btnCopy","btnMove","actions","draggable","onclick","act","parentNode","el","removeChild","thisRow","contains","table","WPTB_Helper","findAncestor","dataTitleColumnSet","td","target","temp","srcList","querySelectorAll","innerHTML","WPTB_List","insertBefore","nextSibling","WPTB_Text","childNodes","WPTB_Image","children","src","text","querySelector","WPTB_Button","WPTB_innerElementSet","parent","type","dragImagesArr","ondragstart","style","opacity","remove","dataTransfer","setDragImage","setData","a","e","preventDefault","buttonsTinyMceInit","tinyMCE","init","inline","plugins","dialog_type","theme","menubar","fixed_toolbar_container","paste_as_text","toolbar","setup","ed","on","row","init_instance_callback","editor","window","currentEditor","totalWidth","offsetWidth","getElementById","scrollTop","bodyElement","display","position","right","top","listItemsTinyMceInit","appendChild","onmouseleave","iter","observer","MutationObserver","mutations","config","attributes","attributeFilter","observe","node_wptb_element_kind_num","WPTB_ElementOptions","increment","WPTB_Builder","table_id","detectMode","http","XMLHttpRequest","urlSet","ajaxurl","open","setRequestHeader","onreadystatechange","d","readyState","status","ans","JSON","parse","responseText","value","wptbTableSetupEl","WPTB_Parser","WPTB_Table","WPTB_LeftPanel","WPTB_Settings","send","ElementCounters","select","MultipleSelect","initializer","WPTB_Initializer","settings","addEventListener","DOMElementProt","DOMElement","elButton","el_B","el_BDiv","wptbElementMutch","Array","isArray","attributesContainer","setAttribute","name","wptbButtonWrapper","wptbButtonWrapAttributes","wptbButton","wptbButtonAttributes","WPTB_Cell","callback","highlightRow","parentRow","columnCount","parseInt","tds","getElementsByTagName","classToAdd","ttd","highlightColumn","rowCount","tr","padding","jQuery","val","innerBorderWidth","border","wptbPhElement","wptbSpaceBetween","j","WPTB_Space","wptbElementTypeClass","wptbTypeElementArr","wptbListItems","WPTB_ListItem","setCoords","y","x","dataset","yIndex","xIndex","getCoords","coords","appendElement","WPTB_DropHandle","thisElem","newElementProxy","includes","wptbDropHandle","wptbDropBorderMarker","wptbDropBorderMarkerTop","wptbDropBorderMarkerRight","wptbDropBorderMarkerBottom","wptbDropBorderMarkerLeft","body","ondragenter","ondragover","ondragleave","ondrop","getData","getDOMParentElement","nodeName","toLowerCase","innerElement","innerElementNext","wptbContainer","onscroll","localName","indics","types","notDragEnter","width","height","offsetHeight","coordinatesElement","getBoundingClientRect","left","Number","indexOf","elementDrag","offsetY","layerY","bottom","priv","key","elemIdClass","prop","cloneNode","properties","affectedEl","wptbButtonA","wptbSize","b","buttonAlignment","justifyContent","buttonAlignmentSelect","selectOption","selectOptionVal","selected","buttonHref","getAttribute","buttonLinkTarget","buttonId","buttonHrefInput","buttonLinkTargetInput","buttonLinkTargetInputId","buttonLinkTargetInputLabel","buttotIdInput","checked","buttonTextColor","color","buttonColor","backgroundColor","buttonTextColorInput","buttonBackgroundColorInput","rgbToHex","elementsA","aTextAlign","textAlign","imageAlignmentSelect","imageLinkHref","inputImageLink","imageLinkTarget","imageLinkTargetInput","imageLinkTargetInputId","imageLinkTargetInputLabel","img","imgWidth","imageWidthInputRange","imageWidthInputNumber","imgAlternativeText","imageAlternativeTextInput","elementFontSize","fontSize","elementTextColor","textFontSizeInputRange","textFontSizeInputNumber","textColorInput","elementList","elementListColor","listColorInput","elementListItem","listItemP","listItemPClasses","elementListClassSelect","listIconSelectLabel","nodeType","listIconSelectLabelId","elementListStyleTypeSelect","elementListItemContent","listItemPTextAlignArr","p","listItemPTextAlignLeftCount","listItemPTextAlignCenterCount","listItemPTextAlignRightCount","elementListAlignmentSelect","maxListItemTAlLeftC","optionsClass","buttons","size","n_Class","num","optionControls","wpColorPicker","change","ui","classe","ps","number","toString","slider","oninput","onchange","alt","href","linkHttpCheckChange","rel","removeAttribute","jc","id","parentNodeSettingItem","listItem","hexToRgb","hex","result","exec","rgb","slice","getDragImageCustom","hostName","location","protocol","hostname","image","button","list","listItemsRecalculateIndex","ulElem","par","listStyleTypeIndex","article","keyCode","duplicate","firstChild","innerText","pText","replace","trim","selectedText","getSelectionText","link","linkArr","linkClean","rows","rowHead","computedStyleRowHead","getComputedStyle","rowHeadChildren","contentsForHeader","tdElements","textContentStyle","textContent","thisRowChildren","titleColumn","titleColumnFontSize","titleColumnColor","titleBackgroundColor","titleAlign","cls","parentElement","txt","getSelection","selection","createRange","settingsPanelClear","wpColorPickerClear","inputId","input","wpPickerContainer","newInput","url","results","decodeURIComponent","anchor","file_frame","wp","media","frames","title","multiple","attachment","state","get","first","toJSON","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","columns","div","classId","stopPropagation","onmouseover","wptbElementButtons","wptbTdBgColorSavedSet","trNumber","tableRows","trBackgroundColor","wptbEvenRowBg","clear","tableHeader","tableTopRowAsHeadSavedSet","wptbTopRowAsHeader","tableBorderColorWidthSavedSet","tableBorderColor","borderColor","tableBorderColorInput","tableBorderWidth","borderWidth","wptbTableBorderWidthSlider","wptbTableBorderWidthNumber","tableTd","applyInnerBorder","innerBorderCheckInput","wptbApplyInnerBorder","wptbTableInnerBorderSlider","wptbTableInnerBorderNumber","tableCells","tableInnerborderNumber","addInnerBorderSize","borderStyle","addCellPadding","addInnerBorder","styles","wptbPreviewTable","marginBottom","addBorderSize","cellPaddingSavedSet","wptbTableCellSlider","wptbTableCellNumber","numberImputSize","wptbNumberInputs","maxCount","maxValue","onkeydown","thisValue","String","substring","onkeyup","wptbTableBorderNumber","wptbTextfontSizeNumber","wptbImageWidthNumber","wptbInnerBorderCheck","tableBorderColorSetArea","createMobileHeadForTable","thisEvent","wptbElement","toggleTableEditMode","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","wpcdFixedToolbar","hasAttribute","innerElements","el_L","item","wptbListItemReturn","divcontent","styleDot","listItemKeyListener","previous","action","content","html","setTimeout","append","selectedCells","multipleCellMode","activateMultipleSelectMode","deactivateMultipleSelectMode","isActivated","pushSelectedCell","cell","flushSelectedCells","getFirst","minXIndex","minYIndex","getLast","maxXIndex","maxYIndex","last","removeAllButFirst","code","columnTitleMobile","WPTB_Parser2","elementHtml","createTextNode","tagName","elems","effectAllowed","ondragend","shortcodePopupWindow","bar","wptb_admin_object","t","messagingArea","WPTB_Stringifier","outerHTML","messagingAreaText","params","security_code","rs","wptbId","stringify","data","elSpaceBetween","spaceBetween","t_space","spaceParent","alert","codeMain","tableColumns","reconstraction","colSpan","rowSpan","mceContentBodys","k","dataMceStyle","contentEditable","spellCheck","mceIds","wptbActions","wptbActionsLength","columnNameDivContainer","columnNameDiv","WPTB_Stringifier2","start","nodeValue","int_elem_arr","attributes_list","internal_elements","inter_elem","array","wptbTableSetup","maxAmountOfCells","maxAmountOfRows","mark","cs","markedCells","noCells","singleCells","multipleCells","column","isSquare","realTimeArray","carried","cols","matriz","items","justAssigned","amount","carriedRowspans","cellsBuffer","cellPointer","xPosition","stepsToMove","celda","drawTable","string","undoSelect","fillTableArray","colspansSums","cells","colspanSumInRow","apply","getActualPointsInRow","points","search","skipInCols","insertRow","wptb_preview_table","cellModeBackground","leftScrollPanelCurtain","wptbPreviewTableTds","recalculateIndexes","trs","maxCols","tdsArr","jMainIter","z","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","rowspan","colspan","call","tdsChildrenNew","tdsInternalElements","tdsIntElemLength","cellStyles","cellXIndex","rowChildInsertBefore","rowNext","findRowspannedCells","difference","actualPoints","addLackingCells","sumRows","totalColspan","nextRow","nextRowChildren","nextRowChildrenLength","tdArr","nextRowChildrenK","jRowChildren","pop","elText2","elP"],"mappings":"AAAA,IAAIA,2BAA2B,SAA3BA,wBAA2B,CAAWC,OAAX,EAAoBC,aAApB,EAAkD;AAAA,QAAfC,IAAe,uEAAR,KAAQ;;AAC7E,QAAIC,OAAOH,QAA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,CAAuB,GAAvB,CAFV;AAAA,QAGI/B,gBAAgBM,SAHpB;AAAA,QAIIL,OAAO,KAJX;;AAMIuJ,eAAW5H,SAAX,CAAqBC,GAArB,CAA0B,qBAA1B;;AAEA4oB,QAAIrnB,SAAJ,GAAgBS,QAAQvD,SAAR,GAAoBuD,IAApB,GAA2B,MAA3C;AACA2mB,YAAQ7jB,WAAR,CAAoB8jB,GAApB;AACAjhB,eAAW7C,WAAX,CAAuB6jB,OAAvB;AACJ,QAAKjhB,cAAL,EAAsB;AAClB,YAAIK,mBAAmBL,eAAepI,SAAf,CAAyBC,KAAzB,CAAgC,0BAAhC,CAAvB;AACA,YAAKwI,oBAAoBC,MAAMC,OAAN,CAAeF,gBAAf,CAAzB,EAA6D;AACzD5J,4BAAgB4J,iBAAiB,CAAjB,CAAhB;AACA3J,mBAAO,IAAP;AACH;;AAED,YAAIiH,0CAAiBqC,eAAerC,UAAhC,EAAJ;AACA,aAAK,IAAIpG,IAAI,CAAb,EAAgBA,IAAIoG,WAAWnG,MAA/B,EAAuCD,GAAvC,EAA6C;AACzC0I,uBAAWQ,YAAX,CAAwB9C,WAAWpG,CAAX,EAAcmJ,IAAtC,EAA4C/C,WAAWpG,CAAX,EAAc2H,KAA1D;AACH;AACJ;;AAED,SAAK/H,IAAL,GAAY,MAAZ;AACA,SAAKP,aAAL,GAAqB,YAAY;AAC7B,eAAOqJ,UAAP;AACH,KAFD;AAGA1J,6BAA0B,IAA1B,EAAgCE,aAAhC,EAA+CC,IAA/C;;AAEA,WAAO,IAAP;AACH,CAhCD","file":"admin.js","sourcesContent":["var applyGenericItemSettings = function ( element, kindIndexProt, copy = false ) {\r\n var node = element.getDOMElement(),\r\n index,\r\n listItems,\r\n copy;\r\n \r\n if ( kindIndexProt == undefined || copy == true ) {\r\n index = document.counter.nextIndex( element.kind );\r\n let wptbElements = document.getElementsByClassName( 'wptb-ph-element' );\r\n let elementIndexesArr = [];\r\n for( let i = 0; i < wptbElements.length; i++ ) {\r\n var regex = new RegExp( 'wptb-element-' + element.kind + '-(\\\\d+)', \"i\" );\r\n let infArr = wptbElements[i].className.match( regex );\r\n if( infArr ) {\r\n elementIndexesArr.push( infArr[1] );\r\n }\r\n }\r\n if( elementIndexesArr.length > 0 ) {\r\n let elementIndexMax = Math.max( ...elementIndexesArr );\r\n index = elementIndexMax + 1;\r\n } else { \r\n index = 1;\r\n }\r\n } else if ( kindIndexProt && ! copy ) {\r\n index = kindIndexProt.split('-')[1];\r\n }\r\n \r\n node.onmouseenter = function (event) {\r\n this.classList.add('wptb-directlyhovered');\r\n let btnDelete = document.createElement( 'span' ),\r\n btnCopy = document.createElement( 'span' ),\r\n btnMove = document.createElement( 'span' ),\r\n actions = document.createElement( 'span' ), i;\r\n\r\n actions.classList.add('wptb-actions');\r\n btnDelete.classList.add('dashicons', 'dashicons-trash', 'wptb-delete-action');\r\n btnCopy.classList.add('dashicons', 'dashicons-admin-page', 'wptb-duplicate-action');\r\n btnMove.classList.add(\"dashicons\", \"dashicons-move\", 'wptb-move-action');\r\n btnMove.draggable = true;\r\n btnDelete.onclick = function (event) {\r\n let act = this.parentNode.parentNode,\r\n el = act.parentNode;\r\n el.removeChild(act);\r\n \r\n if( act.kind == 'text' ) {\r\n let thisRow = el.parentNode\r\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\r\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n }\r\n \r\n };\r\n btnCopy.onclick = function (event) {\r\n let copy;\r\n if (element.kind == 'list') {\r\n var td = event.target.parentNode.parentNode.parentNode,\r\n temp = [],\r\n srcList = event.target.parentNode.parentNode.querySelectorAll('ul li .wptb-list-item-content');\r\n\r\n for (var i = 0; i < srcList.length; i++) {\r\n temp.push(srcList[i].innerHTML);\r\n }\r\n\r\n copy = new WPTB_List( temp, node );\r\n\r\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\r\n } else if (element.kind == 'text') {\r\n var td = event.target.parentNode.parentNode.parentNode;\r\n copy = new WPTB_Text(event.target.parentNode.parentNode.childNodes[0].innerHTML, node);\r\n\r\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\r\n } else if ( element.kind == 'image' ) {\r\n var td = event.target.parentNode.parentNode.parentNode;\r\n copy = new WPTB_Image( event.target.parentNode.parentNode.children[0].children[0].src, node );\r\n\r\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\r\n } else {\r\n var td = event.target.parentNode.parentNode.parentNode,\r\n text = event.target.parentNode.parentNode.childNodes[0].querySelector( 'p' ).innerHTML;\r\n copy = new WPTB_Button( text, node );\r\n\r\n node.parentNode.insertBefore( copy.getDOMElement(), node.nextSibling );\r\n }\r\n \r\n WPTB_innerElementSet( copy.getDOMElement() );\r\n };\r\n let parent = this,\r\n infArr,\r\n type;\r\n infArr = parent.className.match(/wptb-element-(.+)-(\\d+)/i);\r\n type = infArr[1];\r\n let dragImagesArr = WPTB_Helper.dragImagesArr();\r\n btnMove.ondragstart = function (event) {\r\n this.parentNode.style.opacity = 0;\r\n parent.classList.remove( 'wptb-directlyhovered' );\r\n parent.classList.add( 'wptb-moving-mode' );\r\n \r\n event.dataTransfer.setDragImage( dragImagesArr[type], 0, 0 );\r\n event.dataTransfer.setData( 'node', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\r\n event.dataTransfer.setData( 'wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\r\n event.dataTransfer.setData( 'wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1] );\r\n let act = event.target.parentNode.parentNode;\r\n if( act.kind == 'text' ) {\r\n let thisRow = el.parentNode\r\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\r\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n }\r\n };\r\n\r\n if (element.kind === 'button') {\r\n let a = node.querySelector( 'a' ),\r\n target = a.querySelector( 'div' );\r\n a.onclick = function( e ) {\r\n e.preventDefault();\r\n }\r\n WPTB_Helper.buttonsTinyMceInit( target );\r\n } else if (element.kind === 'text') {\r\n tinyMCE.init({\r\n target: node.childNodes[0],\r\n inline: true,\r\n plugins: \"link, paste\",\r\n dialog_type: \"modal\",\r\n theme: 'modern',\r\n menubar: false,\r\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\r\n paste_as_text: true,\r\n toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',\r\n setup : function( ed ) {\r\n ed.on( 'change', function(e) {\r\n let row = WPTB_Helper.findAncestor( node, 'wptb-row' );\r\n if( row.classList.contains( 'wptb-table-head' ) ) {\r\n let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n });\r\n },\r\n init_instance_callback: function (editor) {\r\n window.currentEditor = editor;\r\n //editor.fire('focus');\r\n editor.on('focus', function (e) {\r\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\r\n if (window.currentEditor &&\r\n document.getElementById('wptb_builder').scrollTop >= 55 &&\r\n window.currentEditor.bodyElement.style.display != 'none') {\r\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\r\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\r\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\r\n } else {\r\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\r\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\r\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\r\n }\r\n });\r\n }\r\n });\r\n \r\n } else {\r\n listItems = node.getElementsByClassName( 'wptb-list-item-content' );\r\n for ( let i = 0; i < listItems.length; i++ ) {\r\n WPTB_Helper.listItemsTinyMceInit( listItems[i] );\r\n }\r\n }\r\n\r\n actions.appendChild(btnMove);\r\n actions.appendChild(btnCopy);\r\n actions.appendChild(btnDelete);\r\n this.appendChild( actions );\r\n };\r\n\r\n node.onmouseleave = function ( event ) {\r\n this.classList.remove( 'wptb-directlyhovered' );\r\n let iter = 0;\r\n while( event.target.querySelector( '.wptb-actions' ) && iter < 5 ) {\r\n event.target.querySelector( '.wptb-actions' ).remove();\r\n iter++;\r\n }\r\n };\r\n \r\n // Change data-title-column if the title was changed\r\n if( element.kind == 'text' ) {\r\n var observer = new MutationObserver( function( mutations ) {\r\n let row = WPTB_Helper.findAncestor( node, 'wptb-row' );\r\n if( row.classList.contains( 'wptb-table-head' ) ) {\r\n let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n });\r\n var config = { attributes: true, attributeFilter: ['style'] };\r\n observer.observe( element.getDOMElement(), config );\r\n }\r\n\r\n let node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\\d+)/i);\r\n if ( node_wptb_element_kind_num ) {\r\n node.classList.remove( node_wptb_element_kind_num[0] );\r\n }\r\n if ( ! node.classList.contains( 'wptb-ph-element' ) ) {\r\n node.classList.add( 'wptb-ph-element' );\r\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\r\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\r\n }\r\n } else {\r\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\r\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\r\n }\r\n }\r\n new WPTB_ElementOptions( element, index, kindIndexProt );\r\n\r\n document.counter.increment(element.kind);\r\n};","","(function () {\r\n var WPTB_Builder = function () {\r\n var table_id = WPTB_Helper.detectMode();\r\n if ( table_id ) {\r\n var http = new XMLHttpRequest(),\r\n urlSet = ajaxurl + \"?action=get_table\" + '&id=' + table_id;\r\n http.open('GET', urlSet, true);\r\n http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\r\n http.onreadystatechange = function (d) {\r\n if (this.readyState == 4 && this.status == 200) {\r\n var ans = JSON.parse(http.responseText);\r\n document.getElementById('wptb-setup-name').value = ans[0];\r\n \r\n if( ans[1] ) {\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\r\n let wptbTableSetupEl = document.getElementsByClassName('wptb-table-setup')[0];\r\n wptbTableSetupEl.appendChild( WPTB_Parser( ans[1] ) );\r\n WPTB_Table();\r\n WPTB_LeftPanel();\r\n WPTB_Settings();\r\n } else {\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\r\n }\r\n \r\n return;\r\n }\r\n };\r\n http.send(null);\r\n } else {\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\r\n }\r\n document.counter = new ElementCounters();\r\n document.select = new MultipleSelect();\r\n\r\n var initializer = WPTB_Initializer();\r\n settings = WPTB_Settings();\r\n };\r\n\r\n document.addEventListener('DOMContentLoaded', WPTB_Builder);\r\n})();","var WPTB_Button = function( text, DOMElementProt ) {\r\n \r\n var DOMElement = document.createElement('div'),\r\n elButton = document.createElement('div'),\r\n el_B = document.createElement('a'),\r\n el_BDiv = document.createElement( 'div' ),\r\n kindIndexProt = undefined,\r\n copy = false;\r\n\r\n DOMElement.classList.add('wptb-button-container', 'wptb-size-M', 'wptb-');\r\n elButton.classList.add('wptb-button-wrapper');\r\n el_BDiv.classList.add('wptb-button');\r\n el_BDiv.innerHTML = text != undefined ? text : 'Button Text';\r\n \r\n // Creation of a new button when copying to avoid errors when assigning new event handlers.\r\n if ( DOMElementProt ) {\r\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\r\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\r\n kindIndexProt = wptbElementMutch[1];\r\n copy = true;\r\n }; \r\n var attributesContainer = [...DOMElementProt.attributes];\r\n if ( attributesContainer.length > 0 ) {\r\n for( let i = 0; i < attributesContainer.length; i++ ) {\r\n DOMElement.setAttribute(attributesContainer[i].name, attributesContainer[i].value);\r\n } \r\n }\r\n \r\n var wptbButtonWrapper = DOMElementProt.querySelector( '.wptb-button-wrapper' );\r\n if ( wptbButtonWrapper ) {\r\n var wptbButtonWrapAttributes = [...wptbButtonWrapper.attributes];\r\n if ( wptbButtonWrapAttributes.length > 0 ) {\r\n for( let i = 0; i < wptbButtonWrapAttributes.length; i++ ) {\r\n if ( wptbButtonWrapAttributes[i].name == 'style') {\r\n elButton.setAttribute( wptbButtonWrapAttributes[i].name, wptbButtonWrapAttributes[i].value );\r\n }\r\n } \r\n }\r\n }\r\n \r\n var wptbButton = DOMElementProt.querySelector( 'a' );\r\n if ( wptbButton ) {\r\n var wptbButtonAttributes = [...wptbButton.attributes];\r\n if ( wptbButtonAttributes.length > 0 ) {\r\n for( let i = 0; i < wptbButtonAttributes.length; i++ ) {\r\n if ( wptbButtonAttributes[i].name == 'style' || \r\n wptbButtonAttributes[i].name == 'href' || \r\n wptbButtonAttributes[i].name == 'target' ) {\r\n el_B.setAttribute( wptbButtonAttributes[i].name, wptbButtonAttributes[i].value );\r\n }\r\n } \r\n }\r\n }\r\n }\r\n \r\n elButton.appendChild(el_B);\r\n el_B.appendChild( el_BDiv );\r\n DOMElement.appendChild(elButton);\r\n \r\n \r\n \r\n this.kind = 'button';\r\n\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n };\r\n\r\n applyGenericItemSettings( this, kindIndexProt, copy );\r\n\r\n return this;\r\n};","var WPTB_Cell = function (callback, DOMElement) {\r\n\r\n function highlightRow(td) {\r\n var parentRow = td.parentNode,\r\n columnCount = parseInt(document.getElementById('wptb-columns-number').value),\r\n tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\r\n for (var i = 0; i < tds.length; i++) {\r\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');\r\n }\r\n for (var i = 0; i < columnCount; i++) {\r\n\r\n var classToAdd = i == 0 ? 'wptb-highlighted-row-first' : i == columnCount - 1 ? 'wptb-highlighted-row-last' : 'wptb-highlighted-row-inner';\r\n var ttd = parentRow.getElementsByTagName('td')[i];\r\n if (ttd !== td) {\r\n ttd.classList.add(classToAdd);\r\n }\r\n }\r\n }\r\n\r\n function highlightColumn(td) {\r\n\r\n var index,\r\n parentRow = td.parentNode;\r\n columnCount = parseInt(document.getElementById('wptb-columns-number').value), rowCount = parseInt(document.getElementById('wptb-rows-number').value), table = document.getElementsByClassName('wptb-preview-table')[0];\r\n for (var i = 0; i < columnCount; i++) {\r\n if (parentRow.getElementsByTagName('td')[i] === td) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n for (var i = 0; i < rowCount; i++) {\r\n var classToAdd = i == 0 ? 'wptb-highlighted-column-first' : i == rowCount - 1 ? 'wptb-highlighted-column-last' : 'wptb-highlighted-column-inner';\r\n var tr = table.getElementsByTagName('tr')[i];\r\n if (tr.getElementsByTagName('td')[index] !== td) {\r\n tr.getElementsByTagName('td')[index].classList.add(classToAdd);\r\n }\r\n }\r\n }\r\n \r\n if( ! DOMElement ) {\r\n DOMElement = document.createElement(\"td\");\r\n\r\n DOMElement.style.padding = jQuery('#wptb-table-padding-number').val() + 'px';\r\n\r\n var innerBorderWidth = jQuery('#wptb-table-inner-border-number').val();\r\n\r\n if (innerBorderWidth != '' && parseInt(innerBorderWidth) != 0) {\r\n DOMElement.style.border = innerBorderWidth + 'px solid ' + jQuery('#wptb-table-border-color').val();\r\n } \r\n\r\n DOMElement.classList.add('wptb-droppable', 'wptb-cell');\r\n }\r\n\r\n DOMElement.draggable = false;\r\n if ( callback ) {\r\n DOMElement.onclick = callback;\r\n }\r\n \r\n WPTB_innerElementSet( DOMElement );\r\n \r\n let wptbPhElement = DOMElement.getElementsByClassName( 'wptb-ph-element' );\r\n \r\n if ( wptbPhElement.length > 0 ) {\r\n for( let i = 0; i < wptbPhElement.length; i++ ) {\r\n\r\n let wptbSpaceBetween = DOMElement.getElementsByClassName( 'wptb-space-between' );\r\n\r\n if ( wptbSpaceBetween.length > 0 ) {\r\n for( let j = 0; j < wptbSpaceBetween.length; j++ ) {\r\n WPTB_Space( wptbSpaceBetween[j] );\r\n }\r\n }\r\n \r\n wptbPhElement[i].getDOMElement = function() {\r\n return wptbPhElement[i];\r\n }\r\n \r\n WPTB_innerElementSet( wptbPhElement[i] );\r\n \r\n let wptbElementTypeClass = wptbPhElement[i].className.match( /wptb-element-((.+-)\\d+)/i );\r\n if( wptbElementTypeClass && Array.isArray( wptbElementTypeClass ) ) {\r\n let wptbTypeElementArr = wptbElementTypeClass[1].split( '-' );\r\n wptbPhElement[i].kind = wptbTypeElementArr[0];\r\n applyGenericItemSettings( wptbPhElement[i], wptbElementTypeClass[1] );\r\n if ( wptbPhElement[i].kind == 'list' ) {\r\n let wptbListItems = wptbPhElement[i].getElementsByTagName( 'li' );\r\n if( wptbListItems.length > 0 ) {\r\n for ( let i = 0; i < wptbListItems.length; i++ ) {\r\n WPTB_ListItem( undefined, wptbListItems[i] );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n };\r\n\r\n this.setCoords = function (y, x) {\r\n var el = this.getDOMElement();\r\n el.dataset.yIndex = y;\r\n el.dataset.xIndex = x;\r\n };\r\n\r\n this.getCoords = function () {\r\n var coords,\r\n el = this.getDOMElement();\r\n coords.x = el.dataset.xIndex;\r\n coords.y = el.dataset.yIndex;\r\n return coords;\r\n };\r\n\r\n this.appendElement = function (node) {\r\n getDOMElement().appendChild(node);\r\n };\r\n\r\n return this;\r\n};","var WPTB_DropHandle = function (thisElem, e) {\r\n \r\n function newElementProxy(el) {\r\n if (el.includes('list')) {\r\n return new WPTB_List();\r\n } else if (el.includes('image')) {\r\n return new WPTB_Image();\r\n } else if (el.includes('text')) {\r\n return new WPTB_Text();\r\n } else if (el.includes('button')) {\r\n return new WPTB_Button();\r\n }\r\n }\r\n \r\n let wptbDropHandle,\r\n wptbDropBorderMarker;\r\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length == 0 ) {\r\n wptbDropHandle = document.createElement( 'div' );\r\n wptbDropHandle.classList.add( 'wptb-drop-handle' );\r\n \r\n wptbDropBorderMarker = document.createElement( 'div' );\r\n wptbDropBorderMarker.classList.add( 'wptb-drop-border-marker' );\r\n \r\n let wptbDropBorderMarkerTop = document.createElement( 'div' ),\r\n wptbDropBorderMarkerRight = document.createElement( 'div' ),\r\n wptbDropBorderMarkerBottom = document.createElement( 'div' ),\r\n wptbDropBorderMarkerLeft = document.createElement( 'div' );\r\n \r\n wptbDropBorderMarkerTop.classList.add( 'wptb-drop-border-marker-top' );\r\n wptbDropBorderMarkerRight.classList.add( 'wptb-drop-border-marker-right' );\r\n wptbDropBorderMarkerBottom.classList.add( 'wptb-drop-border-marker-bottom' );\r\n wptbDropBorderMarkerLeft.classList.add( 'wptb-drop-border-marker-left' );\r\n \r\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerTop );\r\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerRight );\r\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerBottom );\r\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerLeft );\r\n \r\n let body = document.getElementsByTagName( 'body' );\r\n if ( body.length > 0 ) {\r\n body[0].appendChild( wptbDropHandle );\r\n body[0].appendChild( wptbDropBorderMarker );\r\n }\r\n \r\n wptbDropHandle.ondragenter = function () {\r\n\r\n }\r\n\r\n wptbDropHandle.ondragover = function (e) {\r\n e.preventDefault();\r\n }\r\n\r\n wptbDropHandle.ondragleave = function () {\r\n\r\n }\r\n wptbDropHandle.ondrop = function (e) {\r\n e.preventDefault();\r\n let element;\r\n \r\n if ( e.dataTransfer.getData('wptbElement') ) {\r\n element = newElementProxy( e.dataTransfer.getData('wptbElement') );\r\n element = element.getDOMElement();\r\n } else {\r\n element = document.getElementsByClassName( e.dataTransfer.getData('node') )[0];\r\n element.classList.remove( 'wptb-moving-mode' );\r\n element.classList.remove( 'wptb-moving-into-same-elem' );\r\n }\r\n \r\n let td;\r\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\r\n thisElem = wptbDropHandle.getDOMParentElement();\r\n if ( thisElem.nodeName.toLowerCase() == 'td' ) {\r\n td = wptbDropHandle.getDOMParentElement();\r\n td.appendChild( element );\r\n }\r\n } else {\r\n let innerElement = wptbDropHandle.getDOMParentElement();\r\n td = innerElement.parentNode;\r\n \r\n if( wptbDropHandle.dataset.text == 'Abowe Element' ) {\r\n td.insertBefore( element, innerElement );\r\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\r\n let innerElementNext = innerElement.nextSibling;\r\n td.insertBefore( element, innerElementNext );\r\n }\r\n }\r\n \r\n let thisRow = td.parentNode\r\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\r\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n \r\n wptbDropHandle.style.display = 'none';\r\n wptbDropBorderMarker.style.display = 'none';\r\n \r\n WPTB_innerElementSet(element);\r\n }\r\n let wptbContainer = document.querySelector( '.wptb-container' );\r\n wptbContainer.onscroll = function() {\r\n wptbDropHandle.style.display = 'none';\r\n wptbDropBorderMarker.style.display = 'none';\r\n }\r\n } else {\r\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\r\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\r\n }\r\n if( thisElem && thisElem.nodeName.toLowerCase() == 'td' && \r\n thisElem.getElementsByClassName( 'wptb-ph-element' ).length != 0 ) {\r\n return;\r\n }\r\n \r\n let thisRow;\r\n if ( thisElem.localName == 'td' ) {\r\n thisRow = thisElem.parentNode;\r\n } else if ( thisElem.localName == 'div' && thisElem.classList.contains( 'wptb-ph-element' ) ) {\r\n thisRow = thisElem.parentNode.parentNode;\r\n }\r\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\r\n let indics = e.dataTransfer.types;\r\n let notDragEnter = false;\r\n for ( let i = 0; i < indics.length; i++ ) {\r\n let infArr = indics[i].match( /wptbelindic-([a-z]+)/i );\r\n if ( infArr && infArr[1] != 'text' ) {\r\n notDragEnter = true;\r\n break;\r\n }\r\n }\r\n if( notDragEnter ) {\r\n return;\r\n }\r\n }\r\n \r\n wptbDropHandle.style.width = thisElem.offsetWidth + 'px';\r\n let height = thisElem.offsetHeight,\r\n coordinatesElement = thisElem.getBoundingClientRect(),\r\n left = Number( coordinatesElement.left ),\r\n top;\r\n wptbDropHandle.style.left = left + 'px';\r\n \r\n if( e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) != -1 ) {\r\n let elementDrag = document.getElementsByClassName( 'wptb-moving-mode' )[0];\r\n if( thisElem == elementDrag ) {\r\n wptbDropHandle.classList.add('wptb-moving-into-same-elem');\r\n wptbDropBorderMarker.classList.add('wptb-moving-into-same-elem');\r\n } else {\r\n wptbDropHandle.classList.remove('wptb-moving-into-same-elem');\r\n wptbDropBorderMarker.classList.remove('wptb-moving-into-same-elem');\r\n }\r\n }\r\n \r\n wptbDropHandle.getDOMParentElement = function() {\r\n return thisElem;\r\n }\r\n \r\n wptbDropHandle.style.display = 'block';\r\n wptbDropBorderMarker.style.display = 'block';\r\n if( thisElem.nodeName.toLowerCase() != 'td' ) {\r\n let y = e.offsetY==undefined?e.layerY:e.offsetY;\r\n top = Number( coordinatesElement.top ) - Number( 11 );\r\n wptbDropHandle.dataset.text = 'Abowe Element';\r\n if ( y > height/2 ) {\r\n top = Number( coordinatesElement.top ) + height - 1;\r\n wptbDropHandle.dataset.text = 'Below Element';\r\n }\r\n } else {\r\n wptbDropHandle.dataset.text = 'Drop Here';\r\n top = Number( coordinatesElement.top ) + height/2 - 5;\r\n }\r\n wptbDropHandle.style.top = top + 'px';\r\n\r\n wptbDropBorderMarker.style.top = coordinatesElement.top + 'px';\r\n wptbDropBorderMarker.style.left = coordinatesElement.left + 'px';\r\n\r\n wptbDropBorderMarkerTop = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-top' );\r\n wptbDropBorderMarkerTop.style.width = ( Number( thisElem.offsetWidth ) - Number( 1 ) ) + 'px';\r\n\r\n wptbDropBorderMarkerRight = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-right' );\r\n wptbDropBorderMarkerRight.style.height = ( Number( coordinatesElement.bottom ) - Number( coordinatesElement.top ) - 1 ) + 'px';\r\n wptbDropBorderMarkerRight.style.left = wptbDropBorderMarkerTop.style.width;\r\n\r\n wptbDropBorderMarkerBottom = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-bottom' );\r\n wptbDropBorderMarkerBottom.style.width = wptbDropBorderMarkerTop.style.width;\r\n wptbDropBorderMarkerBottom.style.top = wptbDropBorderMarkerRight.style.height;\r\n\r\n wptbDropBorderMarkerLeft = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-left' );\r\n wptbDropBorderMarkerLeft.style.height = wptbDropBorderMarkerRight.style.height;\r\n}","var ElementCounters = function () {\r\n\r\n\tvar priv = [];\r\n\tpriv['text'] = 0;\r\n\tpriv['image'] = 0;\r\n\tpriv['list'] = 0;\r\n\tpriv['button'] = 0;\r\n\r\n\tthis.increment = function (key) {\r\n\t\tif (!(key in priv)) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tpriv[key]++;\r\n\t}\r\n\r\n\tthis.nextIndex = function (key) {\r\n\t\tif (!(key in priv)) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\treturn priv[key] + 1;\r\n\t}\r\n\r\n\treturn this;\r\n\r\n};","var WPTB_ElementOptions = function ( element, index, kindIndexProt ) {\r\n\r\n var node = element.getDOMElement(), elemIdClass;\r\n\r\n prop = document.querySelector(\".wptb-\" + element.kind + \"-options-prototype\").cloneNode(true);\r\n prop.classList.remove(\"wptb-\" + element.kind + \"-options-prototype\"); // remove prototype from the class\r\n elemIdClass = 'wptb-options-' + element.kind + \"-\" + index;\r\n\r\n var properties = prop.getElementsByClassName('wptb-element-property');\r\n\r\n for (var i = 0; i < properties.length; i++) {\r\n properties[i].dataset.element = elemIdClass;\r\n }\r\n\r\n prop.classList.add(elemIdClass);\r\n document.getElementById(\"element-options-group\").appendChild(prop);\r\n \r\n if ( kindIndexProt ) {\r\n if ( element.kind == 'button' ) {\r\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt )[0],\r\n wptbButtonWrapper,\r\n wptbButtonA,\r\n wptbButton,\r\n wptbSize;\r\n \r\n if ( affectedEl ) {\r\n wptbSize = affectedEl.className.match(/wptb-size-([a-z]+)/i);\r\n }\r\n \r\n if( wptbSize && Array.isArray( wptbSize ) ) {\r\n var b = prop.getElementsByClassName('wptb-btn-size-btn');\r\n \r\n for ( var i = 0; i < b.length; i++ ) {\r\n b[i].classList.remove( 'selected' );\r\n \r\n if ( b[i].innerHTML == wptbSize[1] ) {\r\n b[i].classList.add( 'selected' );\r\n }\r\n }\r\n }\r\n \r\n if( affectedEl ) {\r\n wptbButtonWrapper = affectedEl.getElementsByClassName( 'wptb-button-wrapper' );\r\n \r\n wptbButtonA = affectedEl.getElementsByTagName( 'a' );\r\n \r\n wptbButton = affectedEl.getElementsByClassName( 'wptb-button' );\r\n }\r\n \r\n if ( wptbButtonWrapper ) {\r\n let buttonAlignment = wptbButtonWrapper[0].style.justifyContent,\r\n buttonAlignmentSelect = prop.querySelector( 'select[data-type=\"button-alignment\"]' ),\r\n selectOption = buttonAlignmentSelect.getElementsByTagName( 'option' ),\r\n selectOptionVal;\r\n \r\n if ( buttonAlignment == 'flex-start' ) {\r\n selectOptionVal = 'left';\r\n } else if ( buttonAlignment == 'center' || ! buttonAlignment ) {\r\n selectOptionVal = 'center';\r\n } else if ( buttonAlignment == 'flex-end' ) {\r\n selectOptionVal = 'right';\r\n }\r\n \r\n for ( let i = 0; i < selectOption.length; i++ ) {\r\n if ( selectOption[i].value == selectOptionVal ) {\r\n selectOption[i].selected = true;\r\n }\r\n }\r\n }\r\n \r\n if ( wptbButtonA.length > 0 ) {\r\n let buttonHref = wptbButtonA[0].getAttribute( 'href' ), \r\n buttonLinkTarget = wptbButtonA[0].getAttribute( 'target' ),\r\n buttonId = wptbButtonA[0].getAttribute( 'id' ),\r\n \r\n \r\n buttonHrefInput = prop.querySelector( 'input[data-type=\"button-link\"]' ),\r\n buttonLinkTargetInput = prop.querySelector( 'input[data-type=\"button-link-target\"]' ),\r\n buttonLinkTargetInputId = buttonLinkTargetInput.getAttribute( 'id' ),\r\n buttonLinkTargetInputLabel = buttonLinkTargetInput.parentNode.getElementsByTagName( 'label' )[0],\r\n \r\n buttotIdInput = prop.querySelector( 'input[data-type=\"button-id\"]' );\r\n\r\n buttonLinkTargetInputId = buttonLinkTargetInputId + '-' + kindIndexProt.split( '-' )[1];\r\n buttonLinkTargetInput.setAttribute( 'id', buttonLinkTargetInputId );\r\n buttonLinkTargetInputLabel.setAttribute( 'for', buttonLinkTargetInputId );\r\n\r\n buttonHrefInput.value = buttonHref;\r\n\r\n if( buttonLinkTarget && buttonLinkTarget == '_blank') {\r\n buttonLinkTargetInput.checked = true;\r\n }\r\n \r\n buttotIdInput.value = buttonId;\r\n }\r\n \r\n if( wptbButton ) {\r\n let buttonTextColor = wptbButton[0].style.color,\r\n buttonColor = wptbButton[0].style.backgroundColor,\r\n buttonTextColorInput = prop.querySelector( 'input[data-type=\"button-text-color\"]' ),\r\n buttonBackgroundColorInput = prop.querySelector( 'input[data-type=\"button-color\"]' );\r\n \r\n \r\n buttonTextColorInput.value = WPTB_Helper.rgbToHex( buttonTextColor );\r\n \r\n buttonBackgroundColorInput.value = WPTB_Helper.rgbToHex( buttonColor );\r\n \r\n }\r\n } else if ( element.kind == 'image' ) {\r\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\r\n if ( affectedEl.length > 0 ) {\r\n let elementsA = affectedEl[0].getElementsByTagName( 'a' );\r\n if ( elementsA.length > 0 ) {\r\n let a = elementsA[0];\r\n\r\n if ( a ) {\r\n a.onclick = function( e ) {\r\n e.preventDefault();\r\n }\r\n // set select according to the alignment of the image\r\n let aTextAlign = a.style.textAlign,\r\n imageAlignmentSelect = prop.querySelector( 'select[data-type=\"image-alignment\"]' ),\r\n selectOption = imageAlignmentSelect.getElementsByTagName( 'option' );\r\n\r\n for ( let i = 0; i < selectOption.length; i++ ) {\r\n if ( selectOption[i].value == aTextAlign ) {\r\n selectOption[i].selected = true;\r\n }\r\n }\r\n\r\n // set text link for input field of setting panel\r\n let imageLinkHref = a.getAttribute( 'href' ),\r\n inputImageLink = prop.querySelector( 'input[data-type=\"image-link\"]' );\r\n if ( imageLinkHref ) {\r\n inputImageLink.value = imageLinkHref;\r\n }\r\n\r\n // set checkbox for target of link \r\n let imageLinkTarget = a.getAttribute( 'target' ),\r\n imageLinkTargetInput = prop.querySelector( 'input[data-type=\"image-link-target\"]' ),\r\n imageLinkTargetInputId = imageLinkTargetInput.getAttribute( 'id' ),\r\n imageLinkTargetInputLabel = imageLinkTargetInput.parentNode.getElementsByTagName( 'label' )[0];\r\n\r\n imageLinkTargetInputId = imageLinkTargetInputId + '-' + kindIndexProt.split( '-' )[1];\r\n\r\n imageLinkTargetInput.setAttribute( 'id', imageLinkTargetInputId );\r\n imageLinkTargetInputLabel.setAttribute( 'for', imageLinkTargetInputId );\r\n\r\n if ( imageLinkTarget && imageLinkTarget == '_blank' ) {\r\n imageLinkTargetInput.checked = true;\r\n }\r\n\r\n let img = a.getElementsByTagName( 'img' );\r\n if ( img.length > 0 ) {\r\n // set value for input fields of image size\r\n let imgWidth = img[0].style.width;\r\n if ( imgWidth ) {\r\n let imageWidthInputRange = prop.querySelector( 'input[type=\"range\"][data-type=\"image-size\"]' ),\r\n imageWidthInputNumber = prop.querySelector( 'input[type=\"number\"][data-type=\"image-size\"]' );\r\n\r\n imageWidthInputRange.value = parseInt( imgWidth );\r\n imageWidthInputNumber.value = parseInt( imgWidth );\r\n }\r\n\r\n // set value for input field of alternative text image\r\n let imgAlternativeText = img[0].getAttribute('alt'),\r\n imageAlternativeTextInput = prop.querySelector( 'input[type=\"text\"][data-type=\"alternative-text\"]' );\r\n\r\n imageAlternativeTextInput.value = imgAlternativeText;\r\n }\r\n }\r\n }\r\n }\r\n } else if ( element.kind == 'text' ) {\r\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\r\n if ( affectedEl.length > 0 ) {\r\n let elementFontSize = affectedEl[0].style.fontSize,\r\n elementTextColor = affectedEl[0].style.color;\r\n let textFontSizeInputRange = prop.querySelector( 'input[type=\"range\"][data-type=\"font-size\"]' ),\r\n textFontSizeInputNumber = prop.querySelector( 'input[type=\"number\"][data-type=\"font-size\"]' ),\r\n textColorInput = prop.querySelector( 'input[type=\"text\"][data-type=\"color\"]' );\r\n\r\n textFontSizeInputRange.value = parseInt( elementFontSize );\r\n textFontSizeInputNumber.value = parseInt( elementFontSize );\r\n textColorInput.value = WPTB_Helper.rgbToHex( elementTextColor );\r\n }\r\n } else if ( element.kind == 'list' ) {\r\n let elementList = document.getElementsByClassName( 'wptb-element-' + kindIndexProt );\r\n if ( elementList.length > 0 ) {\r\n let elementListColor = elementList[0].querySelector( 'p' ).style.color;\r\n let listColorInput = prop.querySelector( 'input[type=\"text\"][data-type=\"list-text-color\"]' );\r\n listColorInput.value = WPTB_Helper.rgbToHex( elementListColor );\r\n \r\n let elementListItem = elementList[0].querySelectorAll( 'li' );\r\n if ( elementListItem.length > 0 ) {\r\n let listItemP = elementListItem[0].querySelector( 'p' );\r\n let listItemPClasses = listItemP.classList;\r\n //listItemPClasses = [...listItemPClasses];\r\n if ( listItemPClasses.length > 0 ) {\r\n let elementListClassSelect = prop.querySelector( 'select[data-type=\"list-class\"]' );\r\n if ( elementListClassSelect ) {\r\n elementListClassSelect.value = 'unordered';\r\n \r\n let listIconSelectLabel = elementListClassSelect.parentNode.nextSibling;\r\n for ( let i = 0; i < 10; i++ ) {\r\n if ( listIconSelectLabel.nodeType == '1' ) {\r\n break;\r\n } else {\r\n listIconSelectLabel = listIconSelectLabel.nextSibling;\r\n }\r\n }\r\n if ( listIconSelectLabel ) {\r\n let listIconSelectLabelId = listIconSelectLabel.getAttribute( 'id' );\r\n listIconSelectLabel.setAttribute( 'id', listIconSelectLabelId + '-' + kindIndexProt );\r\n listIconSelectLabel.style.display = 'flex';\r\n }\r\n \r\n let elementListStyleTypeSelect = prop.querySelector( 'select[data-type=\"list-style-type\"]' );\r\n if ( elementListStyleTypeSelect ) {\r\n elementListStyleTypeSelect.parentNode.style.display = 'flex';\r\n \r\n if( listItemPClasses.contains( 'wptb-list-style-type-disc' ) ) {\r\n elementListStyleTypeSelect.value = 'disc';\r\n } else if( listItemPClasses.contains( 'wptb-list-style-type-circle' ) ) {\r\n elementListStyleTypeSelect.value = 'circle';\r\n } else if( listItemPClasses.contains( 'wptb-list-style-type-square' ) ) {\r\n elementListStyleTypeSelect.value = 'square';\r\n } else if ( listItemPClasses.contains( 'wptb-list-style-type-none' ) ) {\r\n elementListStyleTypeSelect.value = 'none';\r\n }\r\n }\r\n }\r\n }\r\n }\r\n \r\n let elementListItemContent = elementList[0].getElementsByClassName( 'wptb-list-item-content' );\r\n if ( elementListItemContent.length > 0 ) {\r\n let listItemPTextAlignArr = [];\r\n for ( let i = 0; i < elementListItemContent.length; i++ ) {\r\n let p = elementListItemContent[i].querySelector( 'p' );\r\n if ( p ) {\r\n if ( p.style.textAlign ) {\r\n listItemPTextAlignArr.push( p.style.textAlign );\r\n } else {\r\n listItemPTextAlignArr.push( 'left' );\r\n }\r\n }\r\n \r\n }\r\n \r\n let listItemPTextAlignLeftCount = 0,\r\n listItemPTextAlignCenterCount = 0,\r\n listItemPTextAlignRightCount = 0;\r\n \r\n if ( listItemPTextAlignArr.length > 0 ) {\r\n for ( let i = 0; i < listItemPTextAlignArr.length; i++ ) {\r\n if ( listItemPTextAlignArr[i] ) {\r\n if ( listItemPTextAlignArr[i] == 'left' ) {\r\n listItemPTextAlignLeftCount++;\r\n } else if ( listItemPTextAlignArr[i] == 'center' ) {\r\n listItemPTextAlignCenterCount++;\r\n } else if ( listItemPTextAlignArr[i] == 'right' ) {\r\n listItemPTextAlignRightCount++;\r\n }\r\n }\r\n }\r\n }\r\n \r\n let elementListAlignmentSelect = prop.querySelector( 'select[data-type=\"list-alignment\"]' ),\r\n maxListItemTAlLeftC = Math.max( listItemPTextAlignLeftCount, listItemPTextAlignCenterCount, listItemPTextAlignRightCount );\r\n \r\n if ( listItemPTextAlignLeftCount == maxListItemTAlLeftC ) {\r\n elementListAlignmentSelect.value = 'left';\r\n } else if ( listItemPTextAlignCenterCount == maxListItemTAlLeftC ) {\r\n elementListAlignmentSelect.value = 'center';\r\n } else if ( listItemPTextAlignRightCount == maxListItemTAlLeftC ) {\r\n elementListAlignmentSelect.value = 'right';\r\n }\r\n }\r\n } \r\n }\r\n }\r\n\r\n node.onclick = function () {\r\n var infArr = this.className.match(/wptb-element-((.+-)\\d+)/i),\r\n optionsClass = '.wptb-' + infArr[2] + 'options' +\r\n '.wptb-options-' + infArr[1];\r\n\r\n document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';\r\n document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';\r\n document.getElementById(\"element-options-group\").style.display = 'block';\r\n\r\n var children = document.getElementById(\"element-options-group\").childNodes;\r\n for (var i = 0; i < children.length; i++) {\r\n if (children[i].style)\r\n children[i].style.display = 'none';\r\n }\r\n\r\n document.querySelector(optionsClass).style.display = 'block';\r\n\r\n //var listStyleType, textAlign;\r\n\r\n// switch (element.kind) {\r\n\r\n// case 'text':\r\n// jQuery(prop).find('[data-type=color]').wpColorPicker({ defaultColor: node.style.color });\r\n// prop.querySelector('[type=number][data-type=font-size]').value\r\n// = prop.querySelector('[type=range][data-type=font-size]').value\r\n// = node.style.fontSize.substring(0, node.style.fontSize.length - 2);\r\n// break;\r\n// case 'list':\r\n// textAlign = node.querySelector('li p').style.textAlign;\r\n// listStyleType = node.querySelector('li').style.listStyleType;\r\n// if ( prop.querySelector( 'select[data-type=list-class]' ) ) {\r\n// console.log(textAlign);\r\n// console.log(listStyleType);\r\n// console.log(listStyleType);\r\n// console.log(prop);\r\n// prop.querySelector('select[data-type=list-class]').selectedIndex = ( listStyleType == 'decimal' ? 0 : 1 );\r\n// }\r\n// if ( prop.querySelector('select[data-type=list-style-type]') ) {\r\n// prop.querySelector('select[data-type=list-style-type]').selectedIndex = (listStyleType == 'circle' ? 0 : (listStyleType == 'square' ? 1 : 2));\r\n// }\r\n// if ( prop.querySelector('select[data-type=list-alignment]') ) {\r\n// prop.querySelector('select[data-type=list-alignment]').selectedIndex = (textAlign == 'left' ? 0 : (textAlign == 'center' ? 1 : 2));\r\n// }\r\n// break;\r\n// case 'image':\r\n// break;\r\n// case 'button':\r\n// jQuery(prop).find('[data-type=button-color]').wpColorPicker({ defaultColor: node.style.backgroundColor });\r\n// break;\r\n//\r\n// }\r\n };\r\n\r\n if (element.kind == 'button') {\r\n //We must add this special kind of property, since it is triggered with click event\r\n var buttons = prop.getElementsByClassName('wptb-btn-size-btn');\r\n\r\n for (var i = 0; i < buttons.length; i++) {\r\n buttons[i].onclick = function () {\r\n var size = this.innerHTML,\r\n n_Class = this.dataset.element,\r\n infArr = n_Class.match(/wptb-options-(.+)-(\\d+)/i),\r\n type = infArr[1],\r\n num = infArr[2],\r\n affectedEl = document.getElementsByClassName('wptb-element-' + type + '-' + num)[0];\r\n affectedEl.classList.remove('wptb-size-S');\r\n affectedEl.classList.remove('wptb-size-M');\r\n affectedEl.classList.remove('wptb-size-L');\r\n affectedEl.classList.remove('wptb-size-XL');\r\n affectedEl.classList.add('wptb-size-' + size);\r\n var b = this.parentNode.getElementsByClassName('wptb-btn-size-btn');\r\n for (var i = 0; i < b.length; i++) {\r\n b[i].classList.remove('selected');\r\n }\r\n this.classList.add('selected');\r\n }\r\n }\r\n }\r\n\r\n var optionControls = prop.getElementsByClassName('wptb-element-property');\r\n\r\n for (var i = 0; i < optionControls.length; i++) {\r\n if (optionControls[i].classList.contains('wptb-color-picker')) {\r\n jQuery(optionControls[i]).wpColorPicker({\r\n change: function (event, ui) {\r\n var parent = event.target, classe, type, ps, number;\r\n classe = parent.dataset.element.match(/wptb-options-(.+)-(\\d+)/i);\r\n type = classe[1];\r\n number = classe[2];\r\n affectedEl = document.getElementsByClassName('wptb-element-' + type + '-' + number)[0];\r\n if ( type == 'button' ) {\r\n if (parent.dataset.type == 'button-text-color') {\r\n affectedEl.getElementsByClassName('wptb-button')[0].style.color = ui.color.toString();\r\n } else {\r\n affectedEl.getElementsByClassName('wptb-button')[0].style.backgroundColor = ui.color.toString();\r\n }\r\n } else if( type == 'list' ) {\r\n let ps = affectedEl.querySelectorAll( 'p' );\r\n if( ps.length > 0 ) {\r\n for ( let i = 0; i < ps.length; i++ ) {\r\n ps[i].style.color = ui.color.toString();\r\n }\r\n }\r\n } else {\r\n affectedEl.style.color = ui.color.toString();\r\n }\r\n }\r\n });\r\n }\r\n\r\n if (optionControls[i].dataset.type === 'font-size') {\r\n var slider = optionControls[i].parentNode.parentNode.getElementsByClassName('wptb-text-font-size-slider')[0];\r\n slider.oninput = function () {\r\n this.parentNode.parentNode.getElementsByClassName('wptb-text-font-size-number')[0].value = this.value;\r\n this.parentNode.parentNode.getElementsByClassName('wptb-text-font-size-number')[0].onchange();\r\n }\r\n }\r\n\r\n if (optionControls[i].dataset.type === 'image-size') {\r\n var slider = optionControls[i].parentNode.parentNode.getElementsByClassName('wptb-image-size-slider')[0];\r\n slider.oninput = function () {\r\n this.parentNode.parentNode.getElementsByClassName('wptb-image-width-number')[0].value = this.value;\r\n this.parentNode.parentNode.getElementsByClassName('wptb-image-width-number')[0].onchange();\r\n }\r\n }\r\n\r\n optionControls[i].onchange = function (event) {\r\n\r\n var n_Class = this.dataset.element,\r\n infArr = n_Class.match(/wptb-options-(.+)-(\\d+)/i),\r\n type = infArr[1],\r\n num = infArr[2],\r\n affectedEl = document.getElementsByClassName('wptb-element-' + type + '-' + num)[0],\r\n val = this.value;\r\n\r\n switch (this.dataset.type) {\r\n case 'src':\r\n var img = affectedEl.getElementsByTagName(\"img\")[0];\r\n img.src = this.value;\r\n break;\r\n case 'alternative-text':\r\n var img = affectedEl.getElementsByTagName('img')[0];\r\n img.alt = this.value;\r\n break;\r\n case 'image-link':\r\n affectedEl.getElementsByTagName('a')[0].href = WPTB_Helper.linkHttpCheckChange( this.value );\r\n break;\r\n case 'image-link-target':\r\n if (this.checked == true) {\r\n affectedEl.getElementsByTagName('a')[0].target = '_blank';\r\n } else {\r\n affectedEl.getElementsByTagName('a')[0].target = '_self';\r\n }\r\n break;\r\n case 'image-link-nofollow':\r\n if (this.checked == true) {\r\n affectedEl.getElementsByTagName('a')[0].rel = 'nofollow';\r\n } else {\r\n affectedEl.getElementsByTagName('a')[0].removeAttribute('rel');\r\n }\r\n break;\r\n case 'image-size':\r\n affectedEl.getElementsByTagName('img')[0].style.width = this.value + '%';\r\n affectedEl.getElementsByTagName('img')[0].style.height = 'auto';\r\n this.parentNode.parentNode.getElementsByClassName('wptb-image-size-slider')[0].value = this.value;\r\n break;\r\n case 'image-alignment':\r\n affectedEl.getElementsByTagName( 'img' )[0].parentNode.style.textAlign = this.value;\r\n break;\r\n case 'font-size':\r\n affectedEl.style.fontSize = val + 'px';\r\n break;\r\n case 'button-alignment':\r\n var jc = '';\r\n if (this.value == 'left') {\r\n jc = 'start';\r\n } else if (this.value == 'right') {\r\n jc = 'flex-end';\r\n } else {\r\n jc = 'center';\r\n }\r\n affectedEl.getElementsByClassName('wptb-button-wrapper')[0].style.justifyContent = jc;\r\n break;\r\n case 'button-link':\r\n if ( this.value ) {\r\n affectedEl.getElementsByTagName( 'a' )[0].href = WPTB_Helper.linkHttpCheckChange( this.value );\r\n } else {\r\n affectedEl.getElementsByTagName( 'a' )[0].removeAttribute( 'href' );\r\n }\r\n break;\r\n case 'button-link-target':\r\n if (this.checked == true) {\r\n affectedEl.getElementsByTagName('a')[0].target = '_blank';\r\n } else {\r\n affectedEl.getElementsByTagName('a')[0].target = '_self';\r\n }\r\n break;\r\n case 'button-link-nofollow':\r\n if (this.checked == true) {\r\n affectedEl.getElementsByTagName('a')[0].rel = 'nofollow';\r\n } else {\r\n affectedEl.getElementsByTagName('a')[0].removeAttribute( 'rel' );\r\n }\r\n break;\r\n case 'button-id':\r\n if( this.value ) {\r\n affectedEl.getElementsByTagName( 'a' )[0].id = this.value;\r\n } else {\r\n affectedEl.getElementsByTagName( 'a' )[0].removeAttribute( 'id' );\r\n }\r\n case 'button-color':\r\n break;\r\n case 'list-alignment':\r\n let listItems = affectedEl.querySelectorAll('li');\r\n for (var i = 0; i < listItems.length; i++) {\r\n let p = listItems[i].querySelector( 'p' );\r\n if ( p ) {\r\n p.style.textAlign = this.value;\r\n }\r\n }\r\n break;\r\n case 'list-class':\r\n let parentNode = event.target\r\n .parentNode\r\n .parentNode\r\n .querySelector('[data-type=list-style-type]')\r\n .parentNode,\r\n parentNodeSettingItem = parentNode.parentNode;\r\n if (val == 'unordered') {\r\n parentNode.style.display = 'flex';\r\n \r\n parentNodeSettingItem.querySelector( '.wptb-list-icon-select-label' ).style.display = 'flex';\r\n let listItem = affectedEl.querySelectorAll('li');\r\n for (var i = 0; i < listItem.length; i++) {\r\n let p = listItem[i].querySelector( 'p' );\r\n p.removeAttribute ( 'class' );\r\n p.classList.add( 'wptb-list-style-type-disc' );\r\n }\r\n parentNodeSettingItem.querySelector('[data-type=list-style-type]').value = 'disc';\r\n } else {\r\n parentNode.style.display = 'none';\r\n parentNodeSettingItem.querySelector( '.wptb-list-icon-select-label' ).style.display = 'none';\r\n var listItem = affectedEl.querySelectorAll('li');\r\n for (var i = 0; i < listItem.length; i++) {\r\n let p = listItem[i].querySelector( 'p' );\r\n p.removeAttribute ( 'class' );\r\n }\r\n }\r\n break;\r\n case 'list-style-type':\r\n var listItem = affectedEl.querySelectorAll('li');\r\n for (var i = 0; i < listItem.length; i++) {\r\n let p = listItem[i].querySelector( 'p' );\r\n p.removeAttribute ( 'class' );\r\n p.classList.add( 'wptb-list-style-type-' + val.toLowerCase() );\r\n }\r\n break;\r\n }\r\n }\r\n }\r\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 getDragImageCustom: function ( type ) {\n let hostName = location.protocol + '//' + location.hostname;\n let img = document.createElement( 'img' );\n img.src = hostName + '/wp-content/plugins/wp-table-builder/inc/admin/views/builder/icons/' + type + '.png';\n return img;\n },\n dragImagesArr: function() {\n return {\n text: WPTB_Helper.getDragImageCustom( 'text' ),\n image: WPTB_Helper.getDragImageCustom( 'image' ),\n button: WPTB_Helper.getDragImageCustom( 'button' ),\n list: WPTB_Helper.getDragImageCustom( 'list' )\n };\n },\n listItemsRecalculateIndex: function( ulElem ) {\n let par = ulElem.querySelectorAll( 'p' );\n if ( par.length > 0 ) {\n for ( let i = 0; i < par.length; i++ ) {\n par[i].dataset.listStyleTypeIndex = Number( i ) + 1 + '.';\n }\n }\n },\n listItemsTinyMceInit: function( listItem ) {\n tinyMCE.init({\n target: listItem,\n inline: true,\n plugins: \"link, paste\",\n dialog_type: \"modal\",\n theme: 'modern',\n menubar: false,\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\n paste_as_text: true,\n toolbar: 'bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify',\n setup: function(ed) {\n ed.on('keydown', function(e) {\n let article = e.target.parentNode;\n if ( e.keyCode == 13 ) {\n e.preventDefault();\n let text = e.target.innerHTML;\n let duplicate = new WPTB_ListItem( text, article, true );\n \n article.parentNode.insertBefore( duplicate.getDOMElement(), article );\n WPTB_Helper.listItemsTinyMceInit( duplicate.getDOMElement().firstChild );\n e.target.querySelector( 'p' ).innerText = 'New List Item';\n //tinyMCE.execCommand('mceInsertContent', false, 'New List Item');\n WPTB_Helper.listItemsRecalculateIndex( article.parentNode );\n \n } else if ( e.keyCode == '8' || e.keyCode == '46' ) {\n let p = e.target.querySelector( 'p' );\n let pText = p.innerHTML.replace(/<[^>]+>/g, '');\n pText = pText.replace( /\\s+/g, ' ' ).trim();\n pText = pText.replace( /&nbsp;/g, '').trim();\n \n if( pText == '' ) {\n e.preventDefault();\n e.target.querySelector( 'p' ).innerText = '\\n';\n } else {\n let selectedText = WPTB_Helper.getSelectionText();\n selectedText = selectedText.replace( /\\s+/g, ' ' ).trim();\n selectedText = selectedText.replace( /&nbsp;/g, '' ).trim();\n if( selectedText == pText ) {\n e.preventDefault();\n e.target.querySelector( 'p' ).innerText = '\\n';\n }\n }\n }\n });\n \n ed.on( 'keyup', function( e ) {\n \n });\n },\n init_instance_callback: function (editor) {\n window.currentEditor = editor;\n editor.on('focus', function (e) {\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\n if (window.currentEditor &&\n document.getElementById('wptb_builder').scrollTop >= 55 &&\n window.currentEditor.bodyElement.style.display != 'none') {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\n } else {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\n }\n });\n }\n });\n },\n buttonsTinyMceInit: function( target ) {\n tinyMCE.init({\n target: target,\n inline: true,\n plugins: \"link\",\n dialog_type: \"modal\",\n theme: 'modern',\n menubar: false,\n fixed_toolbar_container: '#wpcd_fixed_toolbar',\n toolbar: 'bold italic strikethrough',\n setup : function(ed) {\n ed.on('keydown', function(e) {\n if (e.keyCode == 13) {\n e.preventDefault();\n }\n });\n },\n init_instance_callback: function (editor) {\n window.currentEditor = editor;\n editor.on('focus', function (e) {\n var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;\n if (window.currentEditor &&\n document.getElementById('wptb_builder').scrollTop >= 55 &&\n window.currentEditor.bodyElement.style.display != 'none') {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'fixed';\n document.getElementById('wpcd_fixed_toolbar').style.right = (totalWidth / 2 - document.getElementById('wpcd_fixed_toolbar').offsetWidth / 2) + 'px';\n document.getElementById('wpcd_fixed_toolbar').style.top = '100px';\n } else {\n document.getElementById('wpcd_fixed_toolbar').style.position = 'static';\n delete document.getElementById('wpcd_fixed_toolbar').style.right;\n delete document.getElementById('wpcd_fixed_toolbar').style.top;\n }\n });\n }\n });\n },\n linkHttpCheckChange: function( link ) {\n if ( link ) {\n if ( link.indexOf( 'http://' ) == -1 && link.indexOf( 'https://' ) == -1 ) {\n let linkArr = link.split( '/' ),\n linkClean;\n if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {\n linkClean = linkArr[linkArr.length - 1];\n }\n return document.location.protocol + '//' + linkClean;\n } else { \n return link;\n }\n } else {\n return '';\n }\n },\n dataTitleColumnSet: function( table ) {\n let rows = table.rows,\n rowHead = rows[0];\n let computedStyleRowHead = getComputedStyle(rowHead);\n \n let rowHeadChildren = rowHead.children;\n let contentsForHeader = {};\n for( let i = 0; i < rowHeadChildren.length; i++ ) {\n let tdElements = rowHeadChildren[i].children;\n for( let j = 0; j < tdElements.length; j++ ) {\n let element = tdElements[j];\n if( element.classList.contains( 'wptb-ph-element' ) ) {\n let textContentStyle = element.getAttribute( 'style' );\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.titleColumn = contentsForHeader[thisRowChildren[j].dataset.xIndex][0];\n thisRowChildren[j].dataset.titleColumnFontSize = contentsForHeader[thisRowChildren[j].dataset.xIndex][1];\n thisRowChildren[j].dataset.titleColumnColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][2];\n thisRowChildren[j].dataset.titleBackgroundColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][3];\n thisRowChildren[j].dataset.titleAlign = contentsForHeader[thisRowChildren[j].dataset.xIndex][4];\n } else {\n thisRowChildren[j].dataset.titleColumn = '';\n thisRowChildren[j].dataset.titleColumnFontSize = '';\n thisRowChildren[j].dataset.titleColumnColor = '';\n thisRowChildren[j].dataset.titleBackgroundColor = '';\n thisRowChildren[j].dataset.titleAlign = '';\n }\n }\n }\n },\n findAncestor: function(el, cls) {\n while ((el = el.parentElement) && !el.classList.contains(cls));\n return el;\n },\n getSelectionText: function() {\n var txt = '';\n if (txt = window.getSelection) {\n txt = window.getSelection().toString();\n } else {\n txt = document.selection.createRange().text;\n }\n return txt;\n },\n settingsPanelClear: function() {\n document.getElementById( 'wptb-top-row-as-header' ).checked = false;\n document.getElementById( 'wptb-table-border-slider' ).value = 0;\n document.getElementById( 'wptb-table-border-number' ).value = 0;\n document.getElementById( 'wptb-inner-border-check' ).checked = false;\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\n document.getElementById( 'wptb-table-inner-border-slider' ).value = 1;\n document.getElementById( 'wptb-table-inner-border-number' ).value = 1;\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-border-color' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-header-bg' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-even-row-bg' );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-odd-row-bg' );\n \n document.getElementById( 'wptb-table-cell-slider' ).value = 15;\n document.getElementById( 'wptb-table-cell-number' ).value = 15;\n },\n wpColorPickerClear: function( inputId ) {\n let input = document.getElementById( inputId );\n let wpPickerContainer = WPTB_Helper.findAncestor( input, 'wp-picker-container' );\n let parent = wpPickerContainer.parentNode;\n parent.removeChild( wpPickerContainer );\n let newInput = document.createElement( 'input' );\n newInput.setAttribute( 'id', inputId );\n newInput.value = \"\";\n parent.appendChild( newInput );\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}\n","var WPTB_Image = function ( src, DOMElementProt ) {\r\n let DOMElement,\r\n kindIndexProt = undefined,\r\n copy = false;\r\n if ( DOMElementProt == undefined ) {\r\n DOMElement = document.createElement('div');\r\n\t let anchor = document.createElement('a'),\r\n\t img = document.createElement('img');\r\n anchor.style.display = 'inline-block';\r\n anchor.appendChild(img);\r\n DOMElement.appendChild(anchor);\r\n \r\n anchor.onclick = function( e ) {\r\n e.preventDefault();\r\n }\r\n \r\n file_frame = wp.media.frames.file_frame = wp.media({\r\n\t\ttitle: 'Select a image to upload',\r\n\t\tbutton: {\r\n\t\t\ttext: 'Use this image'\r\n\t\t},\r\n\t\tmultiple: false\r\n });\r\n // When an image is selected, run a callback.\r\n file_frame.on('select', function () {\r\n attachment = file_frame.state().get('selection').first().toJSON();\r\n img.src = attachment.url;\r\n });\r\n // Finally, open the modal\r\n if (src == undefined) {\r\n file_frame.open();\r\n } else {\r\n img.src = src;\r\n }\r\n } else {\r\n DOMElement = DOMElementProt.cloneNode( true );\r\n \r\n DOMElement.getElementsByTagName( 'a' )[0].onclick = function(e) {\r\n e.preventDefault();\r\n };\r\n \r\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\r\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\r\n kindIndexProt = wptbElementMutch[1];\r\n copy = true;\r\n };\r\n }\r\n \r\n this.kind = 'image';\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n };\r\n\tapplyGenericItemSettings( this, kindIndexProt, copy );\r\n\r\n\treturn this;\r\n};","var WPTB_Initializer = function () {\r\n\r\n const MIN_COLUMNS = 1,\r\n MIN_ROWS = 1,\r\n MAX_COLUMNS = 10,\r\n MAX_ROWS = 10;\r\n\r\n var tableGenerator = document.body;\r\n columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0],\r\n columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0],\r\n rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1],\r\n rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1],\r\n columnsInput = document.getElementById('wptb-columns-number'),\r\n rowsInput = document.getElementById('wptb-rows-number');\r\n \r\n columnsDecrementButton.onclick = function () {\r\n if (columnsInput.value > MIN_COLUMNS) {\r\n columnsInput.value--;\r\n }\r\n };\r\n\r\n columnsIncrementButton.onclick = function () {\r\n if (columnsInput.value < MAX_COLUMNS) {\r\n columnsInput.value++;\r\n }\r\n };\r\n\r\n rowsDecrementButton.onclick = function () {\r\n if (rowsInput.value > MIN_ROWS) {\r\n rowsInput.value--;\r\n }\r\n };\r\n\r\n rowsIncrementButton.onclick = function () {\r\n if (rowsInput.value < MAX_ROWS) {\r\n rowsInput.value++;\r\n }\r\n };\r\n\r\n document.getElementById('wptb-generate-table').onclick = function () {\r\n var columns = document.getElementById('wptb-columns-number').value,\r\n rows = document.getElementById('wptb-rows-number').value;\r\n\r\n WPTB_Table(columns, rows);\r\n }\r\n \r\n// if( document.getElementsByClassName( 'wptb-preview-table' ).length == 0 ) {\r\n// WPTB_LeftPanel();\r\n// }\r\n\r\n};\r\n","var WPTB_innerElementSet = function ( element ) {\n \n function newElementProxy(el) {\n if (el == 'list') {\n return new WPTB_List();\n } else if (el == 'image') {\n return new WPTB_Image();\n } else if (el == 'text') {\n return new WPTB_Text();\n } else if (el == 'button') {\n return new WPTB_Button();\n }\n }\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 = 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 == 'Abowe Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n let thisRow = td.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n } else {\n return;\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n\n WPTB_innerElementSet( element );\n\n return true;\n }\n element.onmouseover = function(e) {\n element.classList.remove( 'wptb-ondragenter' );\n }\n}","var WPTB_LeftPanel = function () {\r\n\r\n var table = document.getElementsByClassName('wptb-preview-table')[0],\r\n wptbElementButtons = document.getElementsByClassName('wptb-element');\r\n \r\n function wptbTdBgColorSavedSet( inputId, trNumber ) {\r\n if ( trNumber > 3 ) return;\r\n if( table ) {\r\n let tableRows = table.getElementsByTagName('tr');\r\n if ( tableRows.length > trNumber ) {\r\n let trBackgroundColor = tableRows[trNumber].style.backgroundColor;\r\n var wptbEvenRowBg = document.getElementById(inputId);\r\n if ( wptbEvenRowBg && trBackgroundColor ) {\r\n wptbEvenRowBg.value = WPTB_Helper.rgbToHex( trBackgroundColor );\r\n }\r\n }\r\n }\r\n \r\n }\r\n \r\n wptbTdBgColorSavedSet( 'wptb-even-row-bg', 1 );\r\n jQuery('#wptb-even-row-bg').wpColorPicker({\r\n change: function ( event, ui ) {\r\n var tableRows = table.getElementsByTagName('tr');\r\n for ( let i = 1; i < tableRows.length; i += 2 ) {\r\n tableRows[i].style.backgroundColor = ui.color.toString();\r\n }\r\n },\r\n clear: function(){\r\n var tableRows = table.getElementsByTagName('tr');\r\n for ( let i = 1; i < tableRows.length; i += 2 ) {\r\n tableRows[i].style.backgroundColor = '';\r\n let tds = tableRows[i].getElementsByTagName('td');\r\n for ( let j = 0; j < tds.length; j++ ) {\r\n tds[j].style.backgroundColor = '';\r\n }\r\n }\r\n },\r\n\r\n });\r\n \r\n wptbTdBgColorSavedSet( 'wptb-odd-row-bg', 2 );\r\n jQuery('#wptb-odd-row-bg').wpColorPicker({\r\n change: function ( event, ui ) {\r\n var tableRows = table.getElementsByTagName('tr');\r\n for ( let i = 2; i < tableRows.length; i += 2 ) {\r\n tableRows[i].style.backgroundColor = ui.color.toString();\r\n }\r\n },\r\n clear: function(){\r\n var tableRows = table.getElementsByTagName('tr');\r\n for ( let i = 2; i < tableRows.length; i += 2 ) {\r\n tableRows[i].style.backgroundColor = '';\r\n let tds = tableRows[i].getElementsByTagName( 'td' );\r\n for ( var j = 0; j < tds.length; j++ ) {\r\n tds[j].style.backgroundColor = '';\r\n }\r\n }\r\n },\r\n });\r\n \r\n wptbTdBgColorSavedSet( 'wptb-table-header-bg', 0 );\r\n jQuery('#wptb-table-header-bg').wpColorPicker({\r\n change: function (event, ui) {\r\n var tableHeader = table.getElementsByTagName('tr')[0];\r\n tableHeader.style.backgroundColor = ui.color.toString();\r\n },\r\n clear: function(){\r\n var tableHeader = table.getElementsByTagName('tr')[0];\r\n tableHeader.style.backgroundColor = '';\r\n let tds = tableHeader.getElementsByTagName('td');\r\n for (var j = 0; j < tds.length; j++) {\r\n tds[j].style.backgroundColor = '';\r\n }\r\n },\r\n });\r\n \r\n function tableTopRowAsHeadSavedSet( table ) {\r\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\r\n \r\n if( table && table.classList.contains( 'wptb-table-preview-head' ) ) {\r\n wptbTopRowAsHeader.checked = true;\r\n } else {\r\n wptbTopRowAsHeader.checked = false;\r\n }\r\n }\r\n tableTopRowAsHeadSavedSet( table );\r\n \r\n function tableBorderColorWidthSavedSet() {\r\n let table = document.getElementsByClassName('wptb-preview-table');\r\n if ( table.length > 0 ) {\r\n let tableBorderColor = table[0].style.borderColor;\r\n if ( tableBorderColor ) {\r\n let tableBorderColorInput = document.getElementById( 'wptb-table-border-color' );\r\n if ( tableBorderColorInput ) {\r\n tableBorderColorInput.value = WPTB_Helper.rgbToHex( tableBorderColor );\r\n }\r\n }\r\n \r\n let tableBorderWidth = table[0].style.borderWidth;\r\n if ( tableBorderWidth ) {\r\n let wptbTableBorderWidthSlider = document.getElementById('wptb-table-border-slider'),\r\n wptbTableBorderWidthNumber = document.getElementById('wptb-table-border-number');\r\n \r\n if ( wptbTableBorderWidthSlider ) {\r\n wptbTableBorderWidthSlider.value = parseInt( tableBorderWidth );\r\n }\r\n if ( wptbTableBorderWidthNumber ) {\r\n wptbTableBorderWidthNumber.value = parseInt( tableBorderWidth );\r\n }\r\n }\r\n \r\n \r\n let tableTd = table[0].querySelector( 'td' );\r\n let applyInnerBorder = tableTd.style.borderWidth;\r\n if ( applyInnerBorder ) {\r\n let innerBorderCheckInput = document.getElementById( 'wptb-inner-border-check' );\r\n let wptbApplyInnerBorder = document.getElementById( 'wptb-apply-inner-border' );\r\n if ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) {\r\n if ( innerBorderCheckInput ) {\r\n innerBorderCheckInput.checked = true;\r\n \r\n if ( wptbApplyInnerBorder ) {\r\n wptbApplyInnerBorder.classList.add( 'visible' );\r\n let wptbTableInnerBorderSlider = document.getElementById( 'wptb-table-inner-border-slider' );\r\n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\r\n wptbTableInnerBorderSlider.value = parseInt( applyInnerBorder );\r\n wptbTableInnerBorderNumber.value = parseInt( applyInnerBorder );\r\n }\r\n }\r\n } else {\r\n innerBorderCheckInput.checked = false;\r\n }\r\n }\r\n \r\n if ( ( tableBorderWidth && parseInt( tableBorderWidth ) > 0 ) || ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) ) {\r\n document.getElementById( 'wptb-table-border-color-set-area' ).style.display = '';\r\n }\r\n }\r\n }\r\n \r\n tableBorderColorWidthSavedSet();\r\n\r\n jQuery('#wptb-table-border-color').wpColorPicker({\r\n change: function (event, ui) {\r\n var tableCells = table.getElementsByTagName('td');\r\n table.style.border = document.querySelector('#wptb-table-border-number').value + 'px solid ' + ui.color.toString();\r\n\r\n for (var i = 0; i < tableCells.length; i++) {\r\n let tableInnerborderNumber = document.querySelector('#wptb-table-inner-border-number').value;\r\n if ( document.getElementById('wptb-inner-border-check').checked ) {\r\n tableCells[i].style.border = ( tableInnerborderNumber != 0 ? tableInnerborderNumber : 1 ) + 'px solid ' + ui.color.toString();\r\n }\r\n }\r\n },\r\n clear: function() {\r\n var tableCells = table.getElementsByTagName('td');\r\n table.style.borderColor = '';\r\n\r\n for (var i = 0; i < tableCells.length; i++) {\r\n tableCells[i].style.borderColor = '';\r\n }\r\n }\r\n });\r\n\r\n function addInnerBorderSize(value) {\r\n var tableCells = table.getElementsByTagName('td');\r\n for (var i = 0; i < tableCells.length; i++) {\r\n tableCells[i].style.borderWidth = document.querySelector('#wptb-table-inner-border-number').value + 'px';\r\n tableCells[i].style.borderStyle = 'solid';\r\n }\r\n }\r\n\r\n function addCellPadding(value) {\r\n var tableCells = table.getElementsByTagName('td');\r\n for (var i = 0; i < tableCells.length; i++) {\r\n tableCells[i].style.padding = value + 'px';\r\n }\r\n }\r\n\r\n function addInnerBorder(checked) {\r\n var styles, color = document.querySelector('#wptb-table-border-color').value != undefined ?\r\n document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';\r\n if ( document.querySelector( '#wptb-table-inner-border-slider' ).value == 0 || document.querySelector( '#wptb-table-inner-border-number' ).value == 0 ) {\r\n document.querySelector( '#wptb-table-inner-border-slider' ).value = 1;\r\n document.querySelector( '#wptb-table-inner-border-number' ).value = 1;\r\n }\r\n let width = document.querySelector( '#wptb-table-inner-border-slider' ).value + 'px';\r\n let wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\r\n if( wptbPreviewTable.length > 0 ) {\r\n if (checked == 'checked') {\r\n document.getElementById('wptb-apply-inner-border').style.marginBottom = '0px';\r\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\r\n for (var i = 0; i < tableCells.length; i++) {\r\n tableCells[i].style.border = width + ' solid ' + color;\r\n }\r\n document.getElementById( 'wptb-apply-inner-border' ).classList.add( 'visible' );\r\n } else {\r\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\r\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\r\n for (var i = 0; i < tableCells.length; i++) {\r\n tableCells[i].style.border = '0px solid ' + color;\r\n }\r\n }\r\n }\r\n \r\n }\r\n\r\n function addBorderSize(value) {\r\n table.style.borderWidth = value + 'px';\r\n table.style.borderStyle = 'solid';\r\n }\r\n \r\n function cellPaddingSavedSet() {\r\n let table = document.getElementsByClassName('wptb-preview-table');\r\n \r\n if ( table.length > 0 ) {\r\n let td = table[0].querySelector( 'td' );\r\n \r\n if ( td ) {\r\n let padding = td.style.padding;\r\n \r\n if ( padding ) {\r\n let wptbTableCellSlider = document.getElementById('wptb-table-cell-slider'),\r\n wptbTableCellNumber = document.getElementById('wptb-table-cell-number');\r\n \r\n if ( wptbTableCellSlider ) {\r\n wptbTableCellSlider.value = parseInt( padding );\r\n }\r\n if ( wptbTableCellNumber ) {\r\n wptbTableCellNumber.value = parseInt( padding );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n \r\n cellPaddingSavedSet();\r\n \r\n function numberImputSize( wptbNumberInputs, maxCount, maxValue ) {\r\n wptbNumberInputs.onkeydown = function() {\r\n let thisValue = this.value;\r\n thisValue = String( thisValue );\r\n if ( thisValue[0] == 0 ) {\r\n this.value = \"\";\r\n } else {\r\n thisValue = thisValue.substring( 0, maxCount );\r\n this.value = thisValue;\r\n }\r\n }\r\n wptbNumberInputs.onkeyup = function() {\r\n let thisValue = this.value;\r\n thisValue = String( thisValue );\r\n if ( thisValue > maxValue ) {\r\n this.value = maxValue;\r\n }\r\n }\r\n }\r\n \r\n let wptbTableBorderNumber = document.getElementById( 'wptb-table-border-number' );\r\n numberImputSize( wptbTableBorderNumber, 1, 50 );\r\n \r\n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\r\n numberImputSize( wptbTableInnerBorderNumber, 1, 50 );\r\n \r\n let wptbTableCellNumber = document.getElementById( 'wptb-table-cell-number' );\r\n numberImputSize( wptbTableCellNumber, 1, 50 );\r\n \r\n let wptbTextfontSizeNumber = document.getElementById( 'wptb-text-font-size-number' );\r\n numberImputSize( wptbTextfontSizeNumber, 1, 50 );\r\n \r\n let wptbImageWidthNumber = document.getElementById( 'wptb-image-width-number' );\r\n numberImputSize( wptbImageWidthNumber, 2, 100 );\r\n \r\n \r\n \r\n document.getElementById('wptb-table-cell-slider').oninput = function () {\r\n document.getElementById('wptb-table-cell-number').value = this.value;\r\n addCellPadding(this.value);\r\n };\r\n\r\n document.getElementById('wptb-table-cell-number').onchange = function () {\r\n document.getElementById('wptb-table-cell-slider').value = this.value;\r\n addCellPadding(this.value);\r\n };\r\n\r\n document.getElementById('wptb-table-border-slider').oninput = function () {\r\n document.getElementById('wptb-table-border-number').value = this.value;\r\n addBorderSize(this.value);\r\n \r\n let wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,\r\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\r\n if ( this.value == 0 && wptbInnerBorderCheck == false ) {\r\n tableBorderColorSetArea.style.display = 'none';\r\n } else {\r\n tableBorderColorSetArea.style.display = '';\r\n }\r\n };\r\n\r\n document.getElementById('wptb-table-border-number').onchange = function () {\r\n document.getElementById('wptb-table-border-slider').value = this.value;\r\n addBorderSize(this.value);\r\n };\r\n\r\n document.getElementById('wptb-table-inner-border-slider').oninput = function () {\r\n document.getElementById('wptb-table-inner-border-number').value = this.value;\r\n addInnerBorderSize(this.value);\r\n };\r\n\r\n document.getElementById('wptb-table-inner-border-number').onchange = function () {\r\n document.getElementById('wptb-table-inner-border-slider').value = this.value;\r\n addInnerBorderSize(this.value);\r\n };\r\n\r\n document.getElementById('wptb-inner-border-check').onchange = function () {\r\n if( table ) {\r\n let val = this.checked ? 'checked' : 'unchecked';\r\n addInnerBorder( val );\r\n let borderWidth = document.getElementById('wptb-table-border-slider').value,\r\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\r\n if( val == 'unchecked' && borderWidth == 0 ) {\r\n tableBorderColorSetArea.style.display = 'none';\r\n } else {\r\n tableBorderColorSetArea.style.display = '';\r\n }\r\n }\r\n \r\n };\r\n \r\n function createMobileHeadForTable( table, thisEvent ) {\r\n \r\n if( thisEvent.checked ) {\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n \r\n table.classList.add( 'wptb-table-preview-head' );\r\n table.rows[0].classList.add( 'wptb-table-head' );\r\n } else {\r\n let rows = table.rows;\r\n table.classList.remove( 'wptb-table-preview-head' );\r\n rows[0].classList.remove( 'wptb-table-head' );\r\n \r\n for ( let i = 1; i < rows.length; i++ ) {\r\n let thisRow = rows[i],\r\n thisRowChildren = thisRow.children;\r\n for( let j = 0; j < thisRowChildren.length; j++ ) {\r\n thisRowChildren[j].removeAttribute( 'data-title-column' );\r\n }\r\n }\r\n }\r\n }\r\n \r\n document.getElementById( 'wptb-top-row-as-header' ).onchange = function () {\r\n createMobileHeadForTable( table, this );\r\n }\r\n\r\n for (var i = 0; i < wptbElementButtons.length; i++) {\r\n wptbElementButtons[i].ondragstart = function (e) {\r\n e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);\r\n e.dataTransfer.setData( 'wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement );\r\n }\r\n }\r\n \r\n if( table ) {\r\n document.getElementById('wptb-activate-cell-management-mode').onclick = table.toggleTableEditMode;\r\n document.getElementById( 'wptb-table-edit-mode-close' ).onclick = table.toggleTableEditMode;\r\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = table.toggleTableEditMode;\r\n document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;\r\n document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;\r\n document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;\r\n document.getElementById('wptb-add-row-after').onclick = table.addRowAfter;\r\n document.getElementById('wptb-add-end-column').onclick = table.addColumnEnd;\r\n document.getElementById('wptb-add-start-column').onclick = table.addColumnStart;\r\n document.getElementById('wptb-add-column-before').onclick = table.addColumnBefore;\r\n document.getElementById('wptb-add-column-after').onclick = table.addColumnAfter;\r\n document.getElementById('wptb-delete-column').onclick = table.deleteColumn;\r\n document.getElementById('wptb-delete-row').onclick = table.deleteRow;\r\n document.getElementById('wptb-merge-cells').onclick = table.mergeCells;\r\n document.getElementById('wptb-split-cell').onclick = table.splitCell;\r\n }\r\n \r\n document.querySelector( '.wptb-left-panel-extend' ).onclick = function() {\r\n let wptbContainer = document.querySelector( '.wptb-container' );\r\n if( wptbContainer ) {\r\n if ( wptbContainer.classList.contains( 'collapsed' ) ) {\r\n wptbContainer.classList.remove( 'collapsed' );\r\n } else {\r\n wptbContainer.classList.add( 'collapsed' );\r\n }\r\n }\r\n };\r\n \r\n // this code hides the \"element parameters\" area \r\n // when clicked outside this element and its \"tinymce\" toolbar \r\n let wptbBuilderPanel = document.getElementsByClassName( 'wptb-builder-panel' )[0];\r\n wptbBuilderPanel.addEventListener( 'click', function( e ) {\r\n if( ! e.target.classList.contains( 'wptb-ph-element' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-ph-element' ) && \r\n ! e.target.classList.contains( 'wptb-fixed-toolbar' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-fixed-toolbar' ) ) {\r\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'table';\r\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'block';\r\n document.getElementById( 'element-options-group' ).style.display = 'none';\r\n let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\r\n if( wpcdFixedToolbar.hasAttribute( 'data-toolbar-active-id' ) ) {\r\n document.getElementById( wpcdFixedToolbar.getAttribute( 'data-toolbar-active-id' ) ).classList.remove( 'toolbar-active' );\r\n }\r\n } \r\n }, false);\r\n \r\n};","var WPTB_List = function ( innerElements, DOMElementProt ) {\r\n\r\n var el_L = document.createElement('ul'), item,\r\n DOMElement = document.createElement('div'),\r\n kindIndexProt = undefined,\r\n copy = false;\r\n DOMElement.classList.add( 'wptb-list-item-container' );\r\n\r\n this.kind = 'list';\r\n\r\n if (innerElements === '') {\r\n //Case for edit mode list\r\n } else if ( !innerElements ) {\r\n for (var i = 0; i < 3; i++) {\r\n item = new WPTB_ListItem( '<p>List Item ' + (i + 1) + '</p>');\r\n el_L.appendChild(item.getDOMElement());\r\n }\r\n } else {\r\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\r\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\r\n kindIndexProt = wptbElementMutch[1];\r\n copy = true;\r\n };\r\n \r\n for ( var i = 0; i < innerElements.length; i++ ) {\r\n let listItem = DOMElementProt.querySelector( 'li' );\r\n item = new WPTB_ListItem( innerElements[i], listItem, true );\r\n el_L.appendChild(item.getDOMElement());\r\n }\r\n }\r\n DOMElement.appendChild(el_L);\r\n //window.addElementOptions('list', elList);\r\n\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n }\r\n applyGenericItemSettings( this, kindIndexProt, copy );\r\n WPTB_Helper.listItemsRecalculateIndex( el_L );\r\n\r\n return this;\r\n};","var WPTB_ListItem = function ( text, DOMElementProt, copy ) {\r\n let wptbListItemReturn;\r\n if ( DOMElementProt == undefined || ( DOMElementProt && copy )) {\r\n if (text == undefined) text = 'New List Item';\r\n var DOMElement = document.createElement('li'),\r\n //divdot = document.createElement('div'),\r\n divcontent = document.createElement('div');\r\n //libullet = document.createElement('li');\r\n //divdot.classList.add('wptb-list-item-style-dot');\r\n divcontent.classList.add('wptb-list-item-content');\r\n //libullet.classList.add('wptb-bullet');\r\n if ( DOMElementProt ) {\r\n let styleDot = DOMElementProt.getAttribute( 'style' );\r\n if ( styleDot ) {\r\n DOMElement.setAttribute( 'style', styleDot );\r\n }\r\n }\r\n //DOMElement.appendChild(divdot);\r\n DOMElement.appendChild(divcontent);\r\n //divdot.appendChild(libullet);\r\n divcontent.innerHTML = text;\r\n divcontent.onkeyup = window.listItemKeyListener;\r\n \r\n wptbListItemReturn = true;\r\n } else {\r\n var DOMElement = DOMElementProt;\r\n var divcontent = DOMElement.getElementsByClassName( 'wptb-list-item-content' )[0];\r\n \r\n divcontent.onkeyup = window.listItemKeyListener;\r\n \r\n wptbListItemReturn = false;\r\n }\r\n \r\n DOMElement.onmouseenter = function (event) {\r\n\r\n var btnDelete = document.createElement('span'),\r\n btnCopy = document.createElement('span'),\r\n actions = document.createElement('span'),\r\n previous,\r\n i;\r\n actions.classList.add('wptb-actions');\r\n btnDelete.classList.add('dashicons', 'dashicons-trash', 'wptb-delete-action');\r\n btnCopy.classList.add('dashicons', 'dashicons-admin-page', 'wptb-duplicate-action');\r\n this.classList.add('wptb-directlyhovered');\r\n\r\n btnDelete.onclick = function () {\r\n var action = this.parentNode, \r\n item = this.parentNode.parentNode,\r\n parent = item.parentNode;\r\n item.removeChild( action );\r\n parent.removeChild( item );\r\n WPTB_Helper.listItemsRecalculateIndex( parent );\r\n };\r\n\r\n btnCopy.onclick = function (event) {\r\n var listItem = event.target.parentNode.parentNode,\r\n content = listItem.querySelector('.wptb-list-item-content'),\r\n html = content.innerHTML;\r\n var duplicate = new WPTB_ListItem( html, listItem, true );\r\n listItem.parentNode.insertBefore( duplicate.getDOMElement(), DOMElement );\r\n WPTB_Helper.listItemsTinyMceInit( duplicate.getDOMElement().firstChild );\r\n setTimeout( function(){\r\n divcontent.innerHTML = html;\r\n WPTB_Helper.listItemsRecalculateIndex( listItem.parentNode );\r\n }, 5 );\r\n };\r\n\r\n actions.append(btnCopy, btnDelete);\r\n this.appendChild(actions);\r\n };\r\n\r\n DOMElement.onmouseleave = function (event) {\r\n this.removeAttribute( 'class' );\r\n let iter = 0;\r\n while( event.target.querySelector( '.wptb-actions' ) && iter < 5 ) {\r\n event.target.querySelector( '.wptb-actions' ).remove();\r\n iter++;\r\n }\r\n };\r\n\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n };\r\n \r\n if ( wptbListItemReturn ) {\r\n return this;\r\n }\r\n};","var MultipleSelect = function () {\r\n\r\n\tvar selectedCells = [],\r\n\t\tmultipleCellMode = false;\r\n\r\n\tthis.activateMultipleSelectMode = function () {\r\n\t\tselectedCells = [];\r\n\t\tvar tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\r\n\t\tfor (var i = 0; i < tds.length; i++) {\r\n\t\t\ttds[i].classList.remove('wptb-highlighted');\r\n\t\t}\r\n\t\tmultipleCellMode = true;\r\n\t}\r\n\r\n\tthis.deactivateMultipleSelectMode = function () {\r\n\t\tmultipleCellMode = false;\r\n\t}\r\n\r\n\tthis.isActivated = function () {\r\n\t\treturn multipleCellMode;\r\n\t}\r\n\r\n\tthis.pushSelectedCell = function (cell) {\r\n\t\tif (!multipleCellMode) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tselectedCells.push(cell);\r\n\t\tcell.classList.add('wptb-highlighted');\r\n\t};\r\n\r\n\tthis.selectedCells = function () {\r\n\t\treturn selectedCells;\r\n\t}\r\n\r\n\tthis.flushSelectedCells = function () {\r\n\t\tselectedCells = [];\r\n\t}\r\n\r\n\tthis.getFirst = function () {\r\n\t\tvar minXIndex = 1000, minYIndex = 1000, first;\r\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\r\n\t\t\tif (minXIndex >= selectedCells[i].dataset.xIndex\r\n\t\t\t\t&& minYIndex >= selectedCells[i].dataset.yIndex) {\r\n\t\t\t\tfirst = selectedCells[i];\r\n\t\t\t\tminXIndex = selectedCells[i].dataset.xIndex;\r\n\t\t\t\tminYIndex = selectedCells[i].dataset.yIndex;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn first;\r\n\t}\r\n\r\n\tthis.getLast = function () {\r\n\t\tvar maxXIndex = -1, maxYIndex = -1, last;\r\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\r\n\t\t\tif (maxXIndex <= selectedCells[i].dataset.xIndex\r\n\t\t\t\t&& maxYIndex <= selectedCells[i].dataset.yIndex) {\r\n\t\t\t\tlast = selectedCells[i];\r\n\t\t\t\tmaxXIndex = selectedCells[i].dataset.xIndex;\r\n\t\t\t\tmaxYIndex = selectedCells[i].dataset.yIndex;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn last;\r\n\t}\r\n\r\n\tthis.removeAllButFirst = function () {\r\n\t\tvar td = this.getFirst();\r\n\t\tfor (var i = 1; i < selectedCells.length; i++) {\r\n\t\t\tselectedCells[i].classList.add('wptb-fused-cell-' + td.dataset.xIndex + '-' + td.dataset.yIndex);\r\n\t\t}\r\n\t}\r\n\r\n\treturn this;\r\n\r\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}","var WPTB_Parser2 = function (code) {\r\n if( Array.isArray( code ) ) {\r\n let elementHtml;\r\n \r\n if ( code.length == 1) {\r\n return elementHtml.appendChild( document.createTextNode( code[0] ) );\r\n }\r\n if( 0 in code ) {\r\n let tagName = code[0];\r\n elementHtml = document.createElement( tagName );\r\n \r\n if ( 1 in code ) {\r\n if( Array.isArray( code[1] ) ) {\r\n let attributes = code[1];\r\n \r\n for( let i = 0; i < attributes.length; i++ ) {\r\n if( Array.isArray( attributes[i] ) ) {\r\n elementHtml.setAttribute(attributes[i][0], attributes[i][1]);\r\n }\r\n }\r\n }\r\n }\r\n \r\n if ( 2 in code ) {\r\n if ( Array.isArray( code[2] ) ) {\r\n for ( let i = 0; i < code[2].length; i++ ) {\r\n if ( typeof code[2][i] === 'string' && tagName.toLowerCase() == 'p' ) {\r\n elementHtml.appendChild( document.createTextNode( code[2][i] ) );\r\n continue;\r\n }\r\n if ( ! WPTB_Parser( code[2][i] ) ) continue;\r\n elementHtml.appendChild( WPTB_Parser( code[2][i] ) );\r\n }\r\n } else if( typeof code[2] === 'string' ) {\r\n elementHtml.appendChild( document.createTextNode( code[2] ) );\r\n }\r\n \r\n }\r\n }\r\n \r\n return elementHtml;\r\n } else {\r\n return false;\r\n }\r\n \r\n}","var WPTB_Settings = function () {\r\n var elems = document.getElementsByClassName('wptb-element');\r\n\r\n for ( var i = 0; i < elems.length; i++ ) {\r\n elems[i].ondragstart = function ( event ) {\r\n event.dataTransfer.effectAllowed = 'move';\r\n event.dataTransfer.setData( 'wptbElement', event.target.dataset.wptbElement );\r\n event.dataTransfer.setData( 'wptbElIndic-' + event.target.dataset.wptbElement, 'wptbElIndic-' + event.target.dataset.wptbElement );\r\n }\r\n elems[i].ondragend = function () {\r\n let wptbDropHandle = document.querySelector( '.wptb-drop-handle' ),\r\n wptbDropBorderMarker = document.querySelector( '.wptb-drop-border-marker' );\r\n if ( wptbDropHandle || wptbDropBorderMarker ) {\r\n wptbDropHandle.style.display = 'none';\r\n wptbDropBorderMarker.style.display = 'none';\r\n }\r\n }\r\n };\r\n \r\n let shortcodePopupWindow = document.getElementsByClassName( 'wptb-shortcode-popup-window-modal' )[0];\r\n document.getElementsByClassName( 'wptb-embed-btn' )[0].onclick = function () {\r\n if( ! this.classList.contains( 'wptb-embed-disable' ) ) {\r\n shortcodePopupWindow.classList.add( 'wptb-shortcode-popup-show' );\r\n }\r\n }\r\n \r\n document.getElementsByClassName( 'wptb-shortcode-popup-dark-area' )[0].onclick = function () {\r\n shortcodePopupWindow.classList.remove( 'wptb-shortcode-popup-show' );\r\n }\r\n \r\n document.getElementsByClassName( 'wptb-shortcode-popup-window-close-icon' )[0].onclick = function () {\r\n shortcodePopupWindow.classList.remove( 'wptb-shortcode-popup-show' );\r\n }\r\n\r\n document.getElementsByClassName( 'wptb-save-btn' )[0].onclick = function () {\r\n let bar = document.querySelector( '.wptb-edit-bar' );\r\n if ( bar && bar.classList.contains( 'visible' ) ) {\r\n let table = document.getElementsByClassName( 'wptb-preview-table' )[0];\r\n table.toggleTableEditMode();\r\n }\r\n\r\n let http = new XMLHttpRequest(),\r\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=save_table\",\r\n t = document.getElementById( 'wptb-setup-name' ).value.trim(),\r\n messagingArea,\r\n code = document.getElementsByClassName( 'wptb-preview-table' );\r\n if( code.length > 0 ) {\r\n code = WPTB_Stringifier( code[0] );\r\n code = code.outerHTML;\r\n } else { \r\n code = '';\r\n }\r\n \r\n if ( t === '' || code === '' ) {\r\n let messagingAreaText = '';\r\n if( t === '' ) messagingAreaText += 'You must assign a name to the table before saving it.</br>';\r\n if( code === '' ) messagingAreaText += 'Table wasn\\'t created';\r\n messagingArea = document.getElementById( 'wptb-messaging-area' );\r\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Error: ' + messagingAreaText + '</div>';\r\n messagingArea.classList.add( 'wptb-warning' );\r\n setTimeout(function () {\r\n messagingArea.removeChild( messagingArea.firstChild );\r\n }, 4000 );\r\n return;\r\n }\r\n\r\n let params = {\r\n title: t,\r\n content: code,\r\n security_code: wptb_admin_object.security_code\r\n };\r\n if (( rs = WPTB_Helper.detectMode() ) || ( rs = document.wptbId )) {\r\n params.id = rs;\r\n }\r\n params = JSON.stringify( params );\r\n\r\n http.open('POST', url, true);\r\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\r\n\r\n http.onreadystatechange = function (action) {\r\n if ( this.readyState == 4 && this.status == 200 ) {\r\n var data = JSON.parse( http.responseText );\r\n messagingArea = document.getElementById( 'wptb-messaging-area' );\r\n\r\n if ( data[0] == 'saved' ) {\r\n document.wptbId = data[1];\r\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully saved.</div>';\r\n document.getElementsByClassName( 'wptb-embed-btn' )[0].classList.remove( 'wptb-embed-disable' );\r\n document.getElementById( 'wptb-embed-shortcode' ).value = '[wptb id=' + data[1] + ']';\r\n } else if( data[0] == 'edited' ) {\r\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully updated.</div>';\r\n } else {\r\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Safety problems</div>';\r\n }\r\n messagingArea.classList.add( 'wptb-success' );\r\n setTimeout( function () {\r\n messagingArea.removeChild( messagingArea.firstChild );\r\n }, 4000 );\r\n }\r\n }\r\n http.send( params );\r\n }\r\n};\r\n","var WPTB_Space = function ( elSpaceBetween ) {\r\n\r\n function newElementProxy(el) {\r\n if (el.includes('list')) {\r\n return new WPTB_List();\r\n } else if (el.includes('image')) {\r\n return new WPTB_Image();\r\n } else if (el.includes('text')) {\r\n return new WPTB_Text();\r\n } else if (el.includes('button')) {\r\n return new WPTB_Button();\r\n }\r\n }\r\n let spaceBetween;\r\n if ( ! elSpaceBetween ) {\r\n spaceBetween = document.createElement('div'), spaceBetween.classList.add('wptb-space-between');\r\n } else {\r\n spaceBetween = elSpaceBetween;\r\n }\r\n\r\n spaceBetween.ondragenter = function () {\r\n this.classList.add('visible');\r\n };\r\n spaceBetween.ondragover = function (event) {\r\n event.preventDefault();\r\n };\r\n\r\n spaceBetween.ondragleave = function () {\r\n this.classList.remove('visible');\r\n };\r\n\r\n spaceBetween.ondrop = function (event) {\r\n event.stopPropagation();\r\n\r\n var p = event.target.nextSibling,\r\n td = event.target,\r\n element, t_space, spaceParent;\r\n\r\n while ( !td.classList.contains('wptb-droppable') ) {\r\n td = td.parentNode;\r\n }\r\n\r\n if (event.dataTransfer.getData('wptbElement')) {\r\n element = newElementProxy(event.dataTransfer.getData('wptbElement'));\r\n this.classList.remove('visible');\r\n\r\n if (p == null) {\r\n td.appendChild(element.getDOMElement());\r\n td.appendChild(new WPTB_Space());\r\n } else {\r\n td.insertBefore(element.getDOMElement(), p);\r\n td.insertBefore(new WPTB_Space(), p);\r\n }\r\n\r\n } else {\r\n alert(event.dataTransfer.getData('node'));\r\n element = document.getElementsByClassName(event.dataTransfer.getData('node'))[0];\r\n t_space = element.nextSibling;\r\n spaceParent = element.parentNode;\r\n if (t_space != undefined) {\r\n spaceParent.removeChild(t_space);\r\n }\r\n\r\n if (p == null) {\r\n td.appendChild(element);\r\n td.appendChild(new WPTB_Space());\r\n } else {\r\n td.insertBefore(element, p);\r\n td.insertBefore(new WPTB_Space(), p);\r\n }\r\n\r\n }\r\n this.classList.remove('visible');\r\n };\r\n \r\n if ( ! elSpaceBetween ) {\r\n return spaceBetween;\r\n }\r\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.dataset.reconstraction = 1;\n \n let tds = code.getElementsByTagName( 'td' );\n if ( tds.length > 0 ) {\n for ( let i = 0; i < tds.length; i++ ) {\n \n for( let i = 0; i < tds.length; i++ ) {\n if( code.dataset.reconstraction == 1 && tds[i].colSpan > 1 || tds[i].rowSpan > 1 ) {\n code.dataset.reconstraction = 0;\n break;\n }\n }\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 innerElements[j].classList.remove( 'wptb-directlyhovered' );\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 wptbActions[0].parentNode.removeChild( wptbActions[0] );\n wptbActionsLength--;\n } \n }\n }\n \n if( tds[i].hasAttribute( 'data-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.titleColumn = tds[i].dataset.titleColumn;\n columnNameDiv.setAttribute( 'style', 'font-size:' + tds[i].dataset.titleColumnFontSize + '; \\n\\\n color:' + tds[i].dataset.titleColumnColor + '; background-color:' + tds[i].dataset.titleBackgroundColor + '; text-align:' + tds[i].dataset.titleAlign + ';' );\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 WPTB_Stringifier2 = function ( node, start = false ) {\r\n\r\n\tif ( node == undefined ) {\r\n\t\treturn '';\r\n\t} else if ( node.tagName == undefined && node.nodeType == 3 ) {\r\n return node.nodeValue;\r\n }\r\n \r\n let code = [],\r\n children,\r\n int_elem_arr = false,\r\n attributes = [...node.attributes],\r\n attributes_list = [],\r\n internal_elements = [];\r\n if ( ( node.parentNode.classList.contains( 'wptb-list-item-content' ) || \r\n node.parentNode.classList.contains( 'mce-content-body' ) ) && \r\n node.tagName.toLowerCase() == 'p' ) {\r\n children = node.childNodes;\r\n int_elem_arr = true;\r\n } else if( node.children.length > 0 ) {\r\n children = node.children;\r\n } else {\r\n children = node.childNodes;\r\n }\r\n if ( attributes.length > 0 ) {\r\n for ( let i = 0; i < attributes.length; i++ ) {\r\n attributes_list[i] = [attributes[i].name, attributes[i].value];\r\n }\r\n } else {\r\n attributes_list = '';\r\n }\r\n \r\n if ( children.length > 0 ) {\r\n for ( let i = 0; i < children.length; i++) {\r\n let inter_elem = WPTB_Stringifier(children[i]);\r\n \r\n if ( Array.isArray( inter_elem ) || int_elem_arr ) {\r\n internal_elements[i] = inter_elem;\r\n } else if ( typeof inter_elem === 'string' && inter_elem ) {\r\n internal_elements = inter_elem;\r\n }\r\n }\r\n } else {\r\n internal_elements = '';\r\n }\r\n \r\n \r\n code.push(node.tagName.toLowerCase(), attributes_list , internal_elements);\r\n \r\n return code;\r\n}","var array = [], WPTB_Table = function (columns, rows) {\r\n\r\n /* The members of the class */\r\n var settings = document.getElementsByClassName('wptb-settings-items'),\r\n wptbTableSetup = document.getElementsByClassName(\"wptb-table-setup\")[0],\r\n table, row, cell,\r\n maxAmountOfCells,\r\n maxAmountOfRows;\r\n\r\n //HERE ARE THE PRIVATE FUNCTIONS\r\n /*\r\n * This function toggles buttons visibility in cell edit mode\r\n * (according to the amount of currently selected cells), and\r\n * highlights visually the clicked cell if it is not highlighted, or\r\n * removes highlight if clicked cell is already highlighted. \r\n * It too toggles the bits of our abstract representation.\r\n * @param Event this is the event instance of the click performed over a cell.\r\n */\r\n var mark = function (event) {\r\n var rs = this.rowSpan,\r\n cs = this.colSpan,\r\n markedCells,\r\n noCells = document.getElementsByClassName('wptb-no-cell-action'),\r\n singleCells = document.getElementsByClassName('wptb-single-action'),\r\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\r\n position = getCoords(this),\r\n row = position[0],\r\n column = position[1];\r\n if (!document.select.isActivated()) {\r\n return;\r\n }\r\n if (this.className.match(/wptb-highlighted/)) {\r\n this.classList.remove('wptb-highlighted');\r\n for (var i = 0; i < rs; i++) {\r\n for (var j = 0; j < cs; j++) {\r\n array[row + i][column + j] = 0;\r\n }\r\n }\r\n } else {\r\n this.classList.add('wptb-highlighted');\r\n for (var i = 0; i < rs; i++) {\r\n for (var j = 0; j < cs; j++) {\r\n array[row + i][column + j] = 1;\r\n }\r\n }\r\n }\r\n\r\n markedCells = document.getElementsByClassName('wptb-highlighted').length;\r\n if (markedCells === 0) {\r\n for (var i = 0; i < multipleCells.length; i++) {\r\n multipleCells[i].classList.remove('visible');\r\n multipleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n for (var i = 0; i < noCells.length; i++) {\r\n noCells[i].classList.add('visible');\r\n noCells[i].removeAttribute('disabled');\r\n }\r\n for (var i = 0; i < singleCells.length; i++) {\r\n singleCells[i].classList.remove('visible');\r\n singleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n } else if (markedCells === 1) {\r\n for (var i = 0; i < multipleCells.length; i++) {\r\n multipleCells[i].classList.remove('visible');\r\n multipleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n for (var i = 0; i < noCells.length; i++) {\r\n noCells[i].classList.remove('visible');\r\n noCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n for (var i = 0; i < singleCells.length; i++) {\r\n singleCells[i].classList.add('visible');\r\n singleCells[i].removeAttribute('disabled');\r\n }\r\n } else {\r\n for (var i = 0; i < multipleCells.length; i++) {\r\n if (table.isSquare(array)) {\r\n multipleCells[i].classList.add('visible');\r\n multipleCells[i].removeAttribute('disabled');\r\n } else {\r\n multipleCells[i].classList.remove('visible');\r\n multipleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n }\r\n for (var i = 0; i < noCells.length; i++) {\r\n noCells[i].classList.remove('visible');\r\n noCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n for (var i = 0; i < singleCells.length; i++) {\r\n singleCells[i].classList.remove('visible');\r\n singleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n }\r\n };\r\n\r\n /* \r\n * This function fills an array with 1's according to the actual design\r\n * of HTML table.\r\n * @returns an array of arrays containing an abstract representation\r\n * of HTML table.\r\n * @deprecated\r\n * */\r\n\r\n var realTimeArray = function () {\r\n var carried = [], tds, cols, matriz = [];\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n carried[i] = 0;\r\n }\r\n\r\n for (var i = 0; i < table.rows.length; i++) {\r\n cols = [];\r\n\r\n var tds = table.rows[i].getElementsByTagName('td');\r\n\r\n for (items = 0; items < tds.length; items++) {\r\n\r\n for (var k = 0; k < tds[items].colSpan; k++) {\r\n cols.push(1);\r\n }\r\n\r\n if (tds[items].rowSpan > 1) {\r\n for (var k = 0; k < tds[items].colSpan; k++) {\r\n carried[items + k] = {\r\n justAssigned: true,\r\n amount: tds[items].rowSpan\r\n };\r\n }\r\n }\r\n }\r\n\r\n for (var k = 0; k < maxAmountOfCells; k++) {\r\n if (typeof carried[k] == 'object' && carried[k].amount > 0) {\r\n carried[k].amount--;\r\n if (carried[k].justAssigned) {\r\n carried[k].justAssigned = false;\r\n } else {\r\n cols.push(1);\r\n }\r\n }\r\n }\r\n\r\n matriz.push(cols);\r\n\r\n }\r\n return matriz;\r\n };\r\n\r\n /*\r\n * This function gets the number and position of cell spaces in current row that are occuped \r\n * by upper rowspanned cells.\r\n * @param number the number of row where we wish to calculate the carried rowspans up to.\r\n * @return an array with the remaining rowspans in each column.\r\n */\r\n var carriedRowspans = function (row) {\r\n var carried = [], tds, cols;\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n carried[i] = 0;\r\n }\r\n\r\n if (row == -1) {\r\n return carried;\r\n }\r\n\r\n for (var i = 0; i <= row; i++) {\r\n cellsBuffer = table.rows[i].getElementsByTagName('td');\r\n cellPointer = 0;\r\n\r\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\r\n stepsToMove = 1;\r\n\r\n if (carried[xPosition]) {\r\n carried[xPosition]--;\r\n } else {\r\n celda = cellsBuffer[cellPointer++];\r\n if (celda.rowSpan > 1) {\r\n for (k = 0; k < celda.colSpan; k++) {\r\n carried[xPosition + k] = celda.rowSpan - 1;\r\n }\r\n stepsToMove = celda.colSpan;\r\n } else if (celda.colSpan > 1) {\r\n stepsToMove = celda.colSpan;\r\n }\r\n }\r\n }\r\n\r\n }\r\n return carried;\r\n };\r\n\r\n /*\r\n * A helpful function for showing\r\n * the abstract table in console.\r\n * @param Array our abstract table.\r\n */\r\n var drawTable = function (a) {\r\n var string = 'DRAWING TABLE:\\n';\r\n for (var i = 0; i < a.length; i++) {\r\n\r\n for (var j = 0; j < a[i].length; j++) {\r\n string += ' ' + a[i][j];\r\n }\r\n string += '\\n';\r\n }\r\n table.isSquare(a);\r\n };\r\n\r\n /*\r\n * It resets all the bits of our abstract representation\r\n * to 0 and removes the highlighting class of all cells.\r\n */\r\n\r\n var undoSelect = function () {\r\n var noCells = document.getElementsByClassName('wptb-no-cell-action'),\r\n singleCells = document.getElementsByClassName('wptb-single-action'),\r\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\r\n tds = table.getElementsByClassName('wptb-highlighted');\r\n while (tds.length) {\r\n tds[0].classList.remove('wptb-highlighted');\r\n }\r\n for (var i = 0; i < array.length; i++) {\r\n for (var j = 0; j < array[i].length; j++) {\r\n array[i][j] = 0;\r\n }\r\n }\r\n for (var i = 0; i < multipleCells.length; i++) {\r\n multipleCells[i].classList.remove('visible');\r\n multipleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n for (var i = 0; i < noCells.length; i++) {\r\n noCells[i].classList.add('visible');\r\n noCells[i].removeAttribute('disabled');\r\n }\r\n for (var i = 0; i < singleCells.length; i++) {\r\n singleCells[i].classList.remove('visible');\r\n singleCells[i].setAttribute('disabled', 'disabled');\r\n }\r\n };\r\n\r\n /*\r\n * This fills the abstract representation of our table with \r\n * zeros, at the start. the max amount of cells is the greatest sum\r\n * of all colspans for row.\r\n */\r\n\r\n var fillTableArray = function () {\r\n var colspansSums = [], a = [];\r\n\r\n //calculate max amount of cells inside a row\r\n for (var i = 0; i < table.rows.length; i++) {\r\n var cells = table.rows[i].getElementsByTagName('td'),\r\n colspanSumInRow = 0;\r\n for (var j = 0; j < cells.length; j++) {\r\n colspanSumInRow += cells[j].colSpan;\r\n }\r\n colspansSums.push(colspanSumInRow);\r\n }\r\n\r\n maxAmountOfCells = Math.max.apply(null, colspansSums);\r\n //calculate max rows\r\n var maxAmountOfRows = table.rows.length;\r\n\r\n // fill with zeros from both values\r\n for (var i = 0; i < maxAmountOfRows; i++) {\r\n a[i] = [];\r\n for (var j = 0; j < maxAmountOfCells; j++) {\r\n a[i].push(0);\r\n }\r\n }\r\n drawTable(a);\r\n return a;\r\n };\r\n\r\n /*\r\n * This function gets the sum of all colspans in a row.\r\n * @param number the number of row to be used as reference.\r\n */\r\n var getActualPointsInRow = function (row) {\r\n var tds = table.rows[row].getElementsByTagName('td'),\r\n points = 0;\r\n for (var i = 0; i < tds.length; i++) {\r\n points += tds[i].colSpan;\r\n }\r\n return points;\r\n }\r\n\r\n /*\r\n * This function gets us the exact coordinates of\r\n * an exact cell, in a more reliable way than xIndex and yIndex,\r\n * these last ones were meant to be used for getting the cell trough them.\r\n * @param DOMElement the cell to get the coordinates.\r\n */\r\n var getCoords = function (search) {\r\n var skipInCols = [], cell;\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n skipInCols[i] = 0;\r\n }\r\n\r\n for (var i = 0; i < table.rows.length; i++) {\r\n var cellsBuffer = table.rows[i].getElementsByTagName('td');\r\n cellPointer = 0;\r\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\r\n stepsToMove = 1;\r\n\r\n if (skipInCols[xPosition]) {\r\n skipInCols[xPosition]--;\r\n } else {\r\n var td = cellsBuffer[cellPointer++];\r\n if (td == search) {\r\n return [i, xPosition];\r\n }\r\n if (td.rowSpan > 1) {\r\n for ( let k = 0; k < td.colSpan; k++ ) {\r\n skipInCols[xPosition + k] = td.rowSpan - 1;\r\n }\r\n stepsToMove = td.colSpan;\r\n } else if (td.colSpan > 1) {\r\n stepsToMove = td.colSpan;\r\n }\r\n }\r\n }\r\n }\r\n };\r\n\r\n jQuery('#wptb-table-header-bg').val('');\r\n jQuery('#wptb-even-row-bg').val('');\r\n jQuery('#wptb-odd-row-bg').val('');\r\n jQuery('#wptb-table-border-color').val('');\r\n jQuery('#wptb-table-inner-border-number,#wptb-table-inner-border-slider').val('0');\r\n jQuery('#wptb-table-border-number,#wptb-table-border-slider').val('0');\r\n jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');\r\n\r\n if (columns || rows) {\r\n //END OF PRIVATE FUNCTIONS\r\n for (var i = 0; i < settings.length; i++) {\r\n if (settings[i].id !== 'wptb-apply-inner-border') {\r\n settings[i].classList.add('visible');\r\n }\r\n }\r\n\r\n //Create a HTML Table element.\r\n table = document.createElement('table');\r\n table.classList.add('wptb-preview-table');\r\n\r\n //Add the data rows.\r\n for (var i = 0; i < rows; i++) {\r\n\r\n row = table.insertRow(-1);\r\n row.classList.add( 'wptb-row' );\r\n\r\n for (var j = 0; j < columns; j++) {\r\n cell = new WPTB_Cell(mark);\r\n cell.setCoords(i, j);\r\n row.appendChild(cell.getDOMElement());\r\n }\r\n }\r\n } else {\r\n let wptb_preview_table = document.getElementsByClassName( 'wptb-preview-table' );\r\n\r\n if (wptb_preview_table.length > 0) {\r\n table = wptb_preview_table[0];\r\n\r\n let cells = table.getElementsByTagName('td');\r\n\r\n if (cells.length > 0) {\r\n for (let i = 0; i < cells.length; i++) {\r\n WPTB_Cell(mark, cells[i]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /*\r\n * This just toggles visibility of cell edit bar, and toggles \r\n * cell selecting mode.\r\n */\r\n\r\n table.toggleTableEditMode = function () {\r\n let bar = document.getElementsByClassName('wptb-edit-bar'),\r\n cellModeBackground = document.getElementById('wptb-cell_mode_background'),\r\n leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),\r\n wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\r\n if (wptbPreviewTable.length > 0) {\r\n wptbPreviewTable = wptbPreviewTable[0];\r\n }\r\n\r\n if (bar.length > 0) {\r\n for (let i = 0; i < bar.length; i++) {\r\n if (bar[i].classList.contains('visible')) {\r\n document.select.deactivateMultipleSelectMode();\r\n bar[i].classList.remove('visible');\r\n cellModeBackground.classList.remove('visible');\r\n leftScrollPanelCurtain.classList.remove('visible');\r\n wptbPreviewTable.classList.remove('wptb-preview-table-manage-cells');\r\n let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');\r\n if (wptbPreviewTableTds.length > 0) {\r\n for (let i = 0; i < wptbPreviewTableTds.length; i++) {\r\n wptbPreviewTableTds[i].classList.remove('wptb-highlighted');\r\n }\r\n }\r\n } else {\r\n document.select.activateMultipleSelectMode();\r\n bar[i].classList.add('visible');\r\n cellModeBackground.classList.add('visible');\r\n leftScrollPanelCurtain.classList.add('visible');\r\n wptbPreviewTable.classList.add('wptb-preview-table-manage-cells');\r\n }\r\n }\r\n\r\n }\r\n }\r\n\r\n /*\r\n * For assigning to each cell xIndex and y Index attributes,\r\n * these are the column number and row number of cell in table. \r\n */\r\n\r\n table.recalculateIndexes = function ( start ) {\r\n let trs = this.getElementsByTagName('tr'), tds, maxCols = 0,\r\n tdsArr = [];\r\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\r\n \r\n for (var i = 0; i < trs.length; i++) {\r\n if ( i == 0 ) {\r\n if ( start == undefined ) {\r\n trs[i].style.backgroundColor = jQuery('#wptb-table-header-bg').val();\r\n }\r\n if( wptbTopRowAsHeader.checked ) {\r\n if( start == undefined ) {\r\n this.classList.add( 'wptb-table-preview-head' ); \r\n trs[i].classList.add( 'wptb-table-head' )\r\n } ;\r\n } else {\r\n if( start == undefined ) {\r\n this.classList.remove( 'wptb-table-preview-head' );\r\n trs[i].classList.remove( 'wptb-table-head' );\r\n }\r\n }\r\n } else {\r\n if (i % 2 == 0) {\r\n if ( start == undefined ) {\r\n trs[i].style.backgroundColor = jQuery('#wptb-odd-row-bg').val();\r\n }\r\n trs[i].classList.remove( 'wptb-table-head' );\r\n } else {\r\n if ( start == undefined ) {\r\n trs[i].style.backgroundColor = jQuery('#wptb-even-row-bg').val();\r\n }\r\n trs[i].classList.remove( 'wptb-table-head' );\r\n }\r\n }\r\n\r\n tdsArr[i];\r\n tds = trs[i].getElementsByTagName('td');\r\n\r\n if (tdsArr[i] == undefined) {\r\n tdsArr[i] = [];\r\n }\r\n\r\n let jMainIter = 0;\r\n for (var j = 0; j < tds.length; j++) {\r\n if (tdsArr[i][j] != undefined) {\r\n for (let y = 0; y < 100; y++) {\r\n if (tdsArr[i][jMainIter] != undefined) {\r\n jMainIter++;\r\n continue;\r\n }\r\n tdsArr[i][jMainIter] = tds[j];\r\n tds[j].dataset.xIndex = jMainIter;\r\n break;\r\n }\r\n } else {\r\n tdsArr[i][j] = tds[j];\r\n tds[j].dataset.xIndex = jMainIter;\r\n }\r\n tds[j].dataset.yIndex = i;\r\n\r\n if (tds[j].colSpan > 1) {\r\n for (let k = 1; k < tds[j].colSpan; k++) {\r\n jMainIter++;\r\n tdsArr[i][jMainIter] = 'tdDummy';\r\n }\r\n }\r\n\r\n if (tds[j].rowSpan > 1) {\r\n for (let x = 1; x < tds[j].rowSpan; x++) {\r\n if (tdsArr[i + x] == undefined) {\r\n tdsArr[i + x] = [];\r\n }\r\n for (let z = 0; z < tds[j].colSpan; z++) {\r\n tdsArr[i + x][jMainIter - tds[j].colSpan + 1 + z ] = 'tdDummy';\r\n }\r\n }\r\n }\r\n jMainIter++;\r\n }\r\n if (j > maxCols) {\r\n maxCols = j;\r\n }\r\n }\r\n this.columns = maxCols;\r\n }\r\n\r\n /*\r\n * As simple as it is: adds a column to the end of table.\r\n */\r\n table.addColumnEnd = function () {\r\n let td,\r\n currentTable = document.getElementsByClassName('wptb-preview-table'),\r\n currentTableTd,\r\n currentTdStyle;\r\n if (currentTable.length > 0) {\r\n currentTableTd = currentTable[0].querySelector('td');\r\n }\r\n\r\n if (currentTableTd) {\r\n currentTdStyle = currentTableTd.getAttribute('style');\r\n }\r\n for (var i = 0; i < table.rows.length; i++) {\r\n td = new WPTB_Cell(mark);\r\n if (currentTdStyle) {\r\n td.getDOMElement().setAttribute('style', currentTdStyle);\r\n }\r\n table.rows[i].appendChild(td.getDOMElement());\r\n array[i].push(0);\r\n }\r\n maxAmountOfCells++;\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * As simple as it looks: adds a column to the start of table.\r\n */\r\n\r\n table.addColumnStart = function () {\r\n let td,\r\n firstCell,\r\n currentTable = document.getElementsByClassName('wptb-preview-table'),\r\n currentTableTd,\r\n currentTdStyle;\r\n if (currentTable.length > 0) {\r\n currentTableTd = currentTable[0].querySelector('td');\r\n }\r\n\r\n if (currentTableTd) {\r\n currentTdStyle = currentTableTd.getAttribute('style');\r\n }\r\n for (var i = 0; i < table.rows.length; i++) {\r\n td = new WPTB_Cell(mark);\r\n if (currentTdStyle) {\r\n td.getDOMElement().setAttribute('style', currentTdStyle);\r\n }\r\n firstCell = table.rows[i].getElementsByTagName('td')[0];\r\n if (firstCell) {\r\n table.rows[i].insertBefore(td.getDOMElement(), firstCell);\r\n } else {\r\n table.rows[i].appendChild(td.getDOMElement());\r\n }\r\n array[i].push(0);\r\n }\r\n\r\n maxAmountOfCells++;\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * Well, not so simple as previous functions.\r\n * It adds a column after a certain column of reference.\r\n * @param integer the column number to be used as reference.\r\n *\tIf empty, then the first highlighted cell is used as reference.\r\n */\r\n\r\n table.addColumnAfter = function (c_pos) {\r\n let rows = table.rows,\r\n cellPointer,\r\n cellsBuffer,\r\n cell = document.querySelector('.wptb-highlighted'),\r\n cellStyle = cell.getAttribute('style'),\r\n pos = c_pos != undefined && typeof c_pos === 'number' ? c_pos : getCoords(cell)[1];\r\n \r\n \r\n \r\n if( maxAmountOfCells - pos - cell.colSpan + 1 == 1 ) {\r\n table.addColumnEnd();\r\n } else {\r\n let pendingInsertion = false,\r\n stepsToMove,\r\n td, bro,\r\n carriedRowspans = [],\r\n currentCell;\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n carriedRowspans.push(0);\r\n }\r\n\r\n for (var i = 0; i < rows.length; i++) {\r\n cellPointer = 0;\r\n cellsBuffer = rows[i].getElementsByTagName('td');\r\n pendingInsertion = false;\r\n for (var xPosition = 0;\r\n xPosition < maxAmountOfCells;\r\n xPosition += stepsToMove) {\r\n stepsToMove = 1;\r\n\r\n if (pendingInsertion) {\r\n td = new WPTB_Cell(mark);\r\n if (cellStyle) {\r\n td.getDOMElement().setAttribute('style', cellStyle);\r\n }\r\n if (currentCell && rows[i].contains(currentCell)) {\r\n bro = currentCell.nextSibling;\r\n if (bro) {\r\n rows[i].insertBefore(td.getDOMElement(), bro);\r\n } else {\r\n rows[i].appendChild(td.getDOMElement());\r\n }\r\n } else {\r\n rows[i].insertBefore(td.getDOMElement(), cellsBuffer[0]);\r\n }\r\n break;\r\n } else if (carriedRowspans[xPosition] > 0) {\r\n // If no pending insertion, let's check if no rowspan from upper cells is pending in current position\r\n if (pos == xPosition) {\r\n pendingInsertion = true;\r\n }\r\n } else {\r\n currentCell = cellsBuffer[cellPointer++];\r\n if (currentCell.rowSpan > 1) {\r\n stepsToMove = currentCell.colSpan;\r\n for (var k = 0; k < currentCell.colSpan; k++) {\r\n carriedRowspans[xPosition + k] = currentCell.rowSpan;\r\n if (xPosition + k == pos) {\r\n pendingInsertion = true;\r\n }\r\n }\r\n } else if (currentCell.colSpan > 1) {\r\n stepsToMove = currentCell.colSpan;\r\n for (var k = 0; k < currentCell.colSpan; k++) {\r\n if (xPosition + k == pos) {\r\n pendingInsertion = true;\r\n }\r\n }\r\n } else if (xPosition == pos) {\r\n pendingInsertion = true;\r\n }\r\n }\r\n }\r\n\r\n for (var l = 0; l < maxAmountOfCells; l++) {\r\n if (carriedRowspans[l] > 0)\r\n carriedRowspans[l]--;\r\n }\r\n\r\n }\r\n\r\n for (var i = 0; i < array.length; i++) {\r\n array[i].push(0);\r\n }\r\n maxAmountOfCells++;\r\n drawTable(array);\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n }\r\n };\r\n\r\n /*\r\n * For preventing us to take a lot of time,\r\n * This is just calling the function addColumnAfter, but\r\n * using the previous column to current one as reference.\r\n * @see addColumnAfter\r\n */\r\n\r\n table.addColumnBefore = function () {\r\n var cell = document.querySelector('.wptb-highlighted'),\r\n pos = getCoords(cell)[1];\r\n\r\n if (pos === 0) {\r\n table.addColumnStart();\r\n } else {\r\n table.addColumnAfter(pos - 1);\r\n }\r\n };\r\n\r\n /*\r\n * Luckily, thisfunction is simple, \r\n * it just add a row to the end of table.\r\n */\r\n\r\n table.addRowToTheEnd = function () {\r\n let r = table.insertRow(-1),\r\n td,\r\n aux,\r\n currentTable = document.getElementsByClassName('wptb-preview-table'),\r\n currentTableTd,\r\n currentTdStyle;\r\n r.classList.add( 'wptb-row' );\r\n if (currentTable.length > 0) {\r\n currentTableTd = currentTable[0].querySelector('td');\r\n }\r\n\r\n if (currentTableTd) {\r\n currentTdStyle = currentTableTd.getAttribute('style');\r\n }\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n td = new WPTB_Cell(mark);\r\n if (currentTdStyle) {\r\n td.getDOMElement().setAttribute('style', currentTdStyle);\r\n }\r\n r.appendChild(td.getDOMElement());\r\n }\r\n aux = Array.from(array[0]);\r\n array.push(aux);\r\n drawTable(array);\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * Yet another simple function, \r\n * it just add a row to the start of table.\r\n */\r\n\r\n table.addRowToTheStart = function () {\r\n let r = table.insertRow(0),\r\n td,\r\n aux,\r\n currentTable = document.getElementsByClassName('wptb-preview-table'),\r\n currentTableTd,\r\n currentTdStyle;\r\n r.classList.add( 'wptb-row' );\r\n if (currentTable.length > 0) {\r\n currentTableTd = currentTable[0].querySelector('td');\r\n }\r\n\r\n if (currentTableTd) {\r\n currentTdStyle = currentTableTd.getAttribute('style');\r\n }\r\n\r\n for (var i = 0; i < maxAmountOfCells; i++) {\r\n td = new WPTB_Cell(mark);\r\n if (currentTdStyle) {\r\n td.getDOMElement().setAttribute('style', currentTdStyle);\r\n }\r\n r.appendChild(td.getDOMElement());\r\n }\r\n aux = Array.from(array[0]);\r\n array.push(aux);\r\n drawTable(array);\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /* \r\n * This function adds a row before the current one.\r\n * Since the biggest factor of problem is a not-started but ongoing rowspan,\r\n * the most of the troubles is not here.\r\n */\r\n\r\n table.addRowBefore = function () {\r\n let cell = document.querySelector('.wptb-highlighted'),\r\n cellStyle = cell.getAttribute('style'),\r\n row = getCoords(cell)[0],\r\n cellNew;\r\n for( let i = row - 1; i >= 0; i-- ) {\r\n let rowChildren = table.rows[i].children;\r\n let rowChildrenLength = rowChildren.length;\r\n if( rowChildrenLength > 0 ) {\r\n for( let j = 0; j < rowChildrenLength; j++ ) {\r\n if( rowChildren[j].rowSpan == 1 ) {\r\n row = i;\r\n cellNew = true;\r\n break;\r\n }\r\n }\r\n }\r\n if ( cellNew ) {\r\n break;\r\n }\r\n }\r\n\r\n if (row === 0) {\r\n table.addRowToTheStart();\r\n } else {\r\n table.addRowAfter( row, cellStyle );\r\n }\r\n };\r\n\r\n /*\r\n * Well... by the name convention of the previous 3 functions,\r\n * it's pretty obvious that this functions attaches a new\r\n * row after highlighted cell row. The greatest obstacle it was\r\n * the possibility of a TR not having the exact amount of columns\r\n * occuped by actual node but rowspanned upper cells. For that purpose\r\n * it was created the function realTimeArray.\r\n * @see realTimeArray\r\n */\r\n\r\n table.addRowAfter = function ( row, cellStyle ) {\r\n let cellRowSpan,\r\n rowAfter,\r\n aux;\r\n \r\n if ( ( row == undefined || typeof row !== 'number' ) && cellStyle == undefined ) {\r\n let cell = document.querySelector('.wptb-highlighted');\r\n cellStyle = cell.getAttribute('style'),\r\n row = getCoords(cell)[0],\r\n cellRowSpan = cell.rowSpan,\r\n rowAfter = row + cellRowSpan - 1;\r\n } else {\r\n rowAfter = row;\r\n }\r\n \r\n \r\n let cellsColSpan = 0;\r\n if ( rowAfter < table.rows.length -1 ) {\r\n for( let i = 0; i <= rowAfter ; i++ ) {\r\n let tableRowsIChildren = table.rows[i].children,\r\n tableRIChildrenLength = tableRowsIChildren.length;\r\n if( tableRIChildrenLength > 0 ) {\r\n for( let j = 0; j < tableRIChildrenLength; j++ ) {\r\n let rowIRowSpan = tableRowsIChildren[j].rowSpan;\r\n\r\n if ( rowIRowSpan - 1 + i > rowAfter ) {\r\n tableRowsIChildren[j].rowSpan++;\r\n }\r\n }\r\n }\r\n }\r\n \r\n let rNext = table.rows[rowAfter + 1],\r\n rNextChildren = rNext.children,\r\n rNextChildrenLength = rNextChildren.length;\r\n \r\n if( rNextChildrenLength > 0 ) {\r\n for ( let i = 0; i < rNextChildrenLength; i++ ) {\r\n cellsColSpan += rNextChildren[i].colSpan;\r\n }\r\n }\r\n } else {\r\n cellsColSpan = array[0].length;\r\n }\r\n \r\n let r = table.insertRow( rowAfter + 1 );\r\n r.classList.add( 'wptb-row' );\r\n \r\n for ( j = 0; j < cellsColSpan; j++ ) {\r\n let td = new WPTB_Cell( mark );\r\n td.getDOMElement().setAttribute( 'style', cellStyle );\r\n r.appendChild( td.getDOMElement() );\r\n }\r\n\r\n aux = Array.from(array[0]);\r\n array.push(aux);\r\n drawTable(array);\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * This function checks the current selected cells\r\n * make a rectangular shape.\r\n * @param Array the abstract table.\r\n * @return false, if not making a rectangle, or\r\n *\tArray an array containing number of rows and columns, if selection makes a rectangle.\r\n */\r\n\r\n table.isSquare = function (a) {\r\n var rowStart = -1,\r\n columnStart = -1,\r\n rowEnd = -1,\r\n columnEnd = -1,\r\n height,\r\n width,\r\n itemsEstimate = 0,\r\n items = 0;\r\n\r\n for (var i = 0; i < a.length; i++) {\r\n for (var j = 0; j < a[i].length; j++) {\r\n if (a[i][j] == 1) {\r\n if ( j < columnStart || columnStart == -1 ) {\r\n columnStart = j;\r\n }\r\n if ( i < rowStart || rowStart == -1 ) {\r\n rowStart = i;\r\n }\r\n }\r\n }\r\n \r\n }\r\n\r\n for (var i = a.length - 1; i > -1; i--) {\r\n for (var j = a[i].length - 1; j > -1; j--) {\r\n if (a[i][j] == 1) {\r\n if ( j > columnEnd ) {\r\n columnEnd = j;\r\n }\r\n if ( i > rowEnd ) {\r\n rowEnd = i;\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (var i = rowStart; i < rowEnd; i++) {\r\n for (var j = columnStart; j < columnEnd; j++) {\r\n if (a[i][j] == 0 || a[i][j] == undefined) {\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n for (var i = 0; i < a.length; i++) {\r\n for (var j = 0; j < a[i].length; j++) {\r\n if (a[i][j] == 1) {\r\n items++;\r\n }\r\n }\r\n }\r\n\r\n height = rowEnd - rowStart + 1;\r\n width = columnEnd - columnStart + 1;\r\n itemsEstimate = height * width;\r\n\r\n if (itemsEstimate !== items) {\r\n return false;\r\n }\r\n return [height, width];\r\n };\r\n\r\n /*\r\n * This function merges all selected cells.\r\n * Well, actually sets the colspan and rowspan of first \r\n * upper left cell in selection and deletes the another selected cells.\r\n */\r\n\r\n table.mergeCells = function () {\r\n var dimensions = table.isSquare(array),\r\n rowspan = dimensions[0],\r\n colspan = dimensions[1],\r\n first = document.querySelector('.wptb-highlighted'),\r\n tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),\r\n tdsChildrenNew = [];\r\n\r\n for (let i = 0; i < tds.length; i++) {\r\n let tdsInternalElements = tds[i].getElementsByClassName('wptb-ph-element');\r\n if (tdsInternalElements.length > 0) {\r\n let tdsIntElemLength = tdsInternalElements.length;\r\n for (let j = 0; j < tdsIntElemLength; j++) {\r\n tdsChildrenNew.push(tdsInternalElements[j]);\r\n }\r\n }\r\n let p = tds[i].parentNode;\r\n p.removeChild(tds[i]);\r\n }\r\n if (tdsChildrenNew.length > 0) {\r\n for (let i = 0; i < tdsChildrenNew.length; i++) {\r\n first.appendChild(tdsChildrenNew[i]);\r\n }\r\n }\r\n\r\n first.colSpan = colspan;\r\n first.rowSpan = rowspan;\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * This functions makes the exact inverse as above.\r\n * It resets colspan and rowspan and appends \r\n * the same amount in cells to the table.\r\n * @bug\r\n */\r\n\r\n table.splitCell = function () {\r\n var cell = document.getElementsByClassName('wptb-highlighted')[0],\r\n rowspan = cell.rowSpan,\r\n colspan = cell.colSpan,\r\n cellStyles = cell.getAttribute('style'),\r\n row = getCoords(cell)[0],\r\n thisRow = table.rows[row],\r\n cellXIndex =cell.dataset.xIndex;\r\n \r\n cell.rowSpan = 1;\r\n cell.colSpan = 1;\r\n \r\n for (let i = 1; i < colspan; i++) {\r\n let td = new WPTB_Cell(mark);\r\n td.getDOMElement().setAttribute('style', cellStyles);\r\n if ( cell.nextSibling ) {\r\n thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );\r\n } else {\r\n thisRow.appendChild( td.getDOMElement() );\r\n }\r\n \r\n }\r\n\r\n if (rowspan > 1) {\r\n for (let i = 1; i < rowspan; i++) {\r\n let rowChildInsertBefore = undefined,\r\n rowNext = table.rows[row + i],\r\n rowChildren = rowNext.children,\r\n rowChildrenLength = rowChildren.length;\r\n \r\n if ( rowChildrenLength > 0 ) {\r\n for ( let k = 0; k < rowChildrenLength; k++ ) {\r\n if ( Number( rowChildren[k].dataset.xIndex ) > Number( cellXIndex ) ) {\r\n rowChildInsertBefore = rowChildren[k];\r\n break;\r\n } \r\n }\r\n }\r\n for ( let j = 0; j < colspan; j++ ) {\r\n let td = new WPTB_Cell( mark );\r\n td.getDOMElement().setAttribute( 'style', cellStyles );\r\n if ( rowChildInsertBefore != undefined ) {\r\n rowNext.insertBefore( td.getDOMElement(), rowChildInsertBefore );\r\n } else {\r\n rowNext.appendChild( td.getDOMElement() );\r\n }\r\n }\r\n }\r\n }\r\n\r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n undoSelect();\r\n };\r\n\r\n /*\r\n * Searches for rowspanned cells up to row number meeting it.\r\n * @param number the number of row where the function\r\n * must search up to.\r\n */\r\n\r\n table.findRowspannedCells = function (row) {\r\n var array = [],\r\n difference;\r\n actualPoints = getActualPointsInRow(row);\r\n if (actualPoints === maxAmountOfCells) {\r\n return [];\r\n }\r\n difference = maxAmountOfCells - actualPoints;\r\n\r\n for (var i = row - 1; i >= 0 && difference; i--) {\r\n var tds = table.rows[i].getElementsByTagName('td');\r\n for (var i = 0; i < tds.length; i++) {\r\n if (tds[i].rowSpan > 1) {\r\n array.push(tds[i]);\r\n difference -= tds[i].colSpan;\r\n }\r\n }\r\n }\r\n return array;\r\n\r\n }\r\n\r\n /*\r\n * This function explores the table and adds \r\n * a cell for each lacking one for each row\r\n * to meet an even amount of cells.\r\n */\r\n\r\n table.addLackingCells = function () {\r\n var sumRows = [];\r\n for (var i = 0; i < table.rows.length; i++) {\r\n sumRows.push(0);\r\n }\r\n\r\n for (var i = 0; i < table.rows.length; i++) {\r\n var tds = table.rows[i].getElementsByTagName('td');\r\n for (var j = 0; j < tds.length; j++) {\r\n if (tds[j].rowSpan > 1) {\r\n for (var k = 1; k < tds[j].rowSpan; k++) {\r\n sumRows[i + k]++;\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (var i = 0; i < table.rows.length; i++) {\r\n var tds = table.rows[i].getElementsByTagName('td'),\r\n totalColspan = 0;\r\n for (var j = 0; j < tds.length; j++) {\r\n totalColspan += tds[j].colSpan;\r\n }\r\n totalColspan += sumRows[i];\r\n difference = maxAmountOfCells - totalColspan;\r\n for (var j = 0; j < difference; j++) {\r\n var td = new WPTB_Cell(mark);\r\n table.rows[i].appendChild(td.getDOMElement());\r\n //table.rows[i].insertBefore( td.getDOMElement(), rows[i].nextSibling );\r\n }\r\n }\r\n };\r\n\r\n /*\r\n * This function deletes the row of currently\r\n * selected cell. \r\n */\r\n\r\n table.deleteRow = function () {\r\n let cell = document.querySelector('.wptb-highlighted'),\r\n cellStyles = cell.getAttribute('style'),\r\n rowspan = cell.rowSpan,\r\n row = getCoords(cell)[0],\r\n thisRow,\r\n aux;\r\n \r\n if ( rowspan == undefined ) rowspan = 1;\r\n \r\n for ( let i = 0; i < rowspan; i++ ) {\r\n thisRow = table.rows[row];\r\n let thisRowChildren = thisRow.children,\r\n nextRow = table.rows[row + 1],\r\n nextRowChildren,\r\n nextRowChildrenLength,\r\n tdArr = [];\r\n\r\n if( nextRow != undefined ) {\r\n nextRowChildren = nextRow.children;\r\n nextRowChildrenLength = nextRowChildren.length;\r\n for (let j = 0; j < thisRowChildren.length; j++) {\r\n if ( thisRowChildren[j].rowSpan > 1 ) {\r\n let td = new WPTB_Cell(mark);\r\n td.getDOMElement().setAttribute('style', cellStyles);\r\n td.getDOMElement().colSpan = thisRowChildren[j].colSpan;\r\n td.getDOMElement().rowSpan = thisRowChildren[j].rowSpan - 1;\r\n\r\n let nextRowChildrenK = undefined;\r\n for ( let k = 0; k < nextRowChildrenLength; k++ ) {\r\n if ( Number( nextRowChildren[k].dataset.xIndex ) > Number( thisRowChildren[j].dataset.xIndex ) ) {\r\n nextRowChildrenK = nextRowChildren[k];\r\n break;\r\n } \r\n }\r\n\r\n if ( nextRowChildrenK ) {\r\n tdArr.push( [td, nextRowChildrenK] );\r\n } else {\r\n tdArr.push( [td] );\r\n }\r\n }\r\n }\r\n\r\n if ( tdArr.length > 0 ) {\r\n for ( let k = 0; k < tdArr.length; k++ ) {\r\n if ( tdArr[k][1] != undefined ) {\r\n nextRow.insertBefore( tdArr[k][0].getDOMElement(), tdArr[k][1] );\r\n } else {\r\n nextRow.appendChild( tdArr[k][0].getDOMElement() );\r\n }\r\n }\r\n }\r\n }\r\n \r\n let tableRows = table.rows;\r\n if ( tableRows.length > 0 ) {\r\n for ( let j = 0; j < row; j++ ) {\r\n let jRowChildren = tableRows[j].children;\r\n if ( jRowChildren.length > 0 ) {\r\n for ( let x = 0; x < jRowChildren.length; x++ ) {\r\n if ( jRowChildren[x].rowSpan - 1 >= row - j ) {\r\n jRowChildren[x].rowSpan--;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n aux = Array.from(array[0]);\r\n array.pop(aux);\r\n drawTable(array);\r\n table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);\r\n \r\n if( table.rows.length == 0 ) {\r\n table.toggleTableEditMode();\r\n wptbTableSetup.innerHTML = '';\r\n WPTB_Helper.settingsPanelClear();\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\r\n }\r\n \r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n undoSelect();\r\n }\r\n\r\n /*\r\n * This function deletes the column of currently\r\n * selected cell. Again, this is way more complicated than\r\n * delete row case.\r\n */\r\n\r\n table.deleteColumn = function () {\r\n let cell = document.querySelector('.wptb-highlighted'),\r\n cellXIndex = cell.dataset.xIndex,\r\n colspan = cell.colSpan;\r\n \r\n for ( let i = 0; i < colspan; i++ ) {\r\n for ( let j = 0; j < table.rows.length; j++ ) {\r\n let rowChildren = table.rows[j].children;\r\n let rowChildrenLength = rowChildren.length;\r\n if( rowChildrenLength > 0 ) {\r\n for ( let k = rowChildrenLength - 1; k >= 0; k-- ) {\r\n if ( Number( rowChildren[k].dataset.xIndex ) == Number( cellXIndex ) ) {\r\n if ( rowChildren[k].colSpan > 1 ) {\r\n rowChildren[k].colSpan--;\r\n } else {\r\n table.rows[j].removeChild( rowChildren[k] );\r\n }\r\n break;\r\n } else if( Number( rowChildren[k].dataset.xIndex ) < Number( cellXIndex ) && \r\n Number( rowChildren[k].dataset.xIndex ) + \r\n Number( rowChildren[k].colSpan -1 ) >= cellXIndex ) {\r\n if ( rowChildren[k].colSpan > 1 ) {\r\n rowChildren[k].colSpan--;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n \r\n for ( let j = 0; j < table.rows.length; j++ ) {\r\n if (array[j] != undefined)\r\n array[j].pop();\r\n }\r\n \r\n maxAmountOfCells--;\r\n \r\n if( table.querySelectorAll( 'td' ).length == 0 ) {\r\n table.toggleTableEditMode();\r\n wptbTableSetup.innerHTML = '';\r\n WPTB_Helper.settingsPanelClear();\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\r\n }\r\n \r\n table.recalculateIndexes();\r\n WPTB_Helper.dataTitleColumnSet( table );\r\n }\r\n undoSelect();\r\n };\r\n\r\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\r\n\r\n array = fillTableArray();\r\n\r\n undoSelect();\r\n drawTable(array);\r\n\r\n wptbTableSetup.appendChild(table);\r\n //if (columns || rows) {\r\n table.recalculateIndexes( true );\r\n //}\r\n\r\n WPTB_LeftPanel();\r\n \r\n // this code gets the ID of the active element in the toolbar \r\n // and stores it in the data attribute of the common container element \"wpcd_fixed_toolbar\"\r\n// let wptbPhElement = document.getElementsByClassName( 'wptb-ph-element' );\r\n// let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\r\n// for ( let i = 0; i < wptbPhElement.length; i++ ) {\r\n// wptbPhElement[i].addEventListener( 'click', function( e ) {\r\n// let wptbToolbar = document.getElementById( 'wpcd_fixed_toolbar' ).children;\r\n// for ( let j = 0; j < wptbToolbar.length; j++ ) {\r\n// let elementStyles = window.getComputedStyle( wptbToolbar[j], 'null' );\r\n// if( elementStyles.getPropertyValue( 'display' ) == 'block' ) {\r\n// wpcdFixedToolbar.dataset.toolbarActiveId = wptbToolbar[j].getAttribute( 'id' );\r\n// }\r\n// }\r\n// }, false );\r\n// }\r\n \r\n// let wptbPanelLeft = document.getElementsByClassName( 'wptb-panel-left' );\r\n// if( wptbPanelLeft.length > 0 ) {\r\n// wptbPanelLeft[0].addEventListener( 'click', function( e ) {\r\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\r\n// document.getElementById( toolbarActiveElementId ).style.display = '';\r\n// }, false );\r\n// }\r\n \r\n// let body = document.getElementsByTagName( 'body' );\r\n// if( body.length > 0 ) {\r\n// body[0].addEventListener( 'click', function( e ) {\r\n// if ( e.target.classList.contains( 'wptb-panel-left' ) || WPTB_Helper.findAncestor( e.target, 'wptb-panel-left' ) ) {\r\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\r\n// document.getElementById( toolbarActiveElementId ).style.display = '';\r\n// }\r\n// }, false );\r\n// }\r\n};","var WPTB_Text = function ( text , DOMElementProt ) {\r\n let DOMElement = document.createElement('div'),\r\n elText2 = document.createElement('div'),\r\n elP = document.createElement('p'),\r\n kindIndexProt = undefined,\r\n copy = false;\r\n \r\n DOMElement.classList.add( 'wptb-text-container' );\r\n\r\n elP.innerHTML = text != undefined ? text : 'Text';\r\n elText2.appendChild(elP);\r\n DOMElement.appendChild(elText2);\r\n if ( DOMElementProt ) {\r\n let wptbElementMutch = DOMElementProt.className.match( /wptb-element-((.+-)\\d+)/i );\r\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\r\n kindIndexProt = wptbElementMutch[1];\r\n copy = true;\r\n };\r\n\r\n let attributes = [...DOMElementProt.attributes];\r\n for( let i = 0; i < attributes.length; i++ ) {\r\n DOMElement.setAttribute(attributes[i].name, attributes[i].value);\r\n }\r\n } \r\n\r\n this.kind = 'text';\r\n this.getDOMElement = function () {\r\n return DOMElement;\r\n };\r\n applyGenericItemSettings( this, kindIndexProt, copy );\r\n\r\n return this;\r\n};"]}
inc/admin/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}document.addEventListener("DOMContentLoaded",function(){var e=WPTB_Helper.detectMode();if(e){var n=new XMLHttpRequest,t=ajaxurl+"?action=get_table&id="+e;n.open("GET",t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(n.responseText);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])),WPTB_Table(),WPTB_LeftPanel(),WPTB_Settings()):document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},n.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_Button=function(e,t){var n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("a"),l=document.createElement("div"),o=void 0,s=!1;if(n.classList.add("wptb-button-container","wptb-size-M","wptb-"),a.classList.add("wptb-button-wrapper"),l.classList.add("wptb-button"),l.innerHTML=null!=e?e:"Button Text",t){var i=t.className.match(/wptb-element-((.+-)\d+)/i);i&&Array.isArray(i)&&(o=i[1],s=!0);var d=[].concat(_toConsumableArray(t.attributes));if(0<d.length)for(var c=0;c<d.length;c++)n.setAttribute(d[c].name,d[c].value);var m=t.querySelector(".wptb-button-wrapper");if(m){var p=[].concat(_toConsumableArray(m.attributes));if(0<p.length)for(var u=0;u<p.length;u++)"style"==p[u].name&&a.setAttribute(p[u].name,p[u].value)}var b=t.querySelector("a");if(b){var g=[].concat(_toConsumableArray(b.attributes));if(0<g.length)for(var y=0;y<g.length;y++)"style"!=g[y].name&&"href"!=g[y].name&&"target"!=g[y].name||r.setAttribute(g[y].name,g[y].value)}}return a.appendChild(r),r.appendChild(l),n.appendChild(a),this.kind="button",this.getDOMElement=function(){return n},applyGenericItemSettings(this,o,s),this},WPTB_Cell=function(e,s){if(!s){(s=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)&&(s.style.border=t+"px solid "+jQuery("#wptb-table-border-color").val()),s.classList.add("wptb-droppable","wptb-cell")}s.draggable=!1,e&&(s.onclick=e),WPTB_innerElementSet(s);var i=s.getElementsByClassName("wptb-ph-element");if(0<i.length)for(var n=function(e){var t=s.getElementsByClassName("wptb-space-between");if(0<t.length)for(var n=0;n<t.length;n++)WPTB_Space(t[n]);i[e].getDOMElement=function(){return i[e]},WPTB_innerElementSet(i[e]);var a=i[e].className.match(/wptb-element-((.+-)\d+)/i);if(a&&Array.isArray(a)){var r=a[1].split("-");if(i[e].kind=r[0],applyGenericItemSettings(i[e],a[1]),"list"==i[e].kind){var l=i[e].getElementsByTagName("li");if(0<l.length)for(var o=0;o<l.length;o++)WPTB_ListItem(void 0,l[o])}}},a=0;a<i.length;a++)n(a);return this.getDOMElement=function(){return s},this.setCoords=function(e,t){var n=this.getDOMElement();n.dataset.yIndex=e,n.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)},this},WPTB_DropHandle=function(i,e){var d=void 0,c=void 0;if(0==document.getElementsByClassName("wptb-drop-handle").length){(d=document.createElement("div")).classList.add("wptb-drop-handle"),(c=document.createElement("div")).classList.add("wptb-drop-border-marker");var t=document.createElement("div"),n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("div");t.classList.add("wptb-drop-border-marker-top"),n.classList.add("wptb-drop-border-marker-right"),a.classList.add("wptb-drop-border-marker-bottom"),r.classList.add("wptb-drop-border-marker-left"),c.appendChild(t),c.appendChild(n),c.appendChild(a),c.appendChild(r);var l=document.getElementsByTagName("body");0<l.length&&(l[0].appendChild(d),l[0].appendChild(c)),d.ondragenter=function(){},d.ondragover=function(e){e.preventDefault()},d.ondragleave=function(){},d.ondrop=function(e){e.preventDefault();var t,n=void 0;e.dataTransfer.getData("wptbElement")?n=(n=(t=e.dataTransfer.getData("wptbElement")).includes("list")?new WPTB_List:t.includes("image")?new WPTB_Image:t.includes("text")?new WPTB_Text:t.includes("button")?new WPTB_Button:void 0).getDOMElement():((n=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).classList.remove("wptb-moving-mode"),n.classList.remove("wptb-moving-into-same-elem"));var a=void 0;if("Drop Here"==d.dataset.text)"td"==(i=d.getDOMParentElement()).nodeName.toLowerCase()&&(a=d.getDOMParentElement()).appendChild(n);else{var r=d.getDOMParentElement();if(a=r.parentNode,"Abowe Element"==d.dataset.text)a.insertBefore(n,r);else if("Below Element"==d.dataset.text){var l=r.nextSibling;a.insertBefore(n,l)}}var o=a.parentNode;if(o.classList.contains("wptb-table-head")){var s=WPTB_Helper.findAncestor(o,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(s)}d.style.display="none",c.style.display="none",WPTB_innerElementSet(n)},document.querySelector(".wptb-container").onscroll=function(){d.style.display="none",c.style.display="none"}}else d=document.getElementsByClassName("wptb-drop-handle")[0],c=document.getElementsByClassName("wptb-drop-border-marker")[0];if(!i||"td"!=i.nodeName.toLowerCase()||0==i.getElementsByClassName("wptb-ph-element").length){var o=void 0;if("td"==i.localName?o=i.parentNode:"div"==i.localName&&i.classList.contains("wptb-ph-element")&&(o=i.parentNode.parentNode),o.classList.contains("wptb-table-head")){for(var s=e.dataTransfer.types,m=!1,p=0;p<s.length;p++){var u=s[p].match(/wptbelindic-([a-z]+)/i);if(u&&"text"!=u[1]){m=!0;break}}if(m)return}d.style.width=i.offsetWidth+"px";var b=i.offsetHeight,g=i.getBoundingClientRect(),y=Number(g.left),f=void 0;if(d.style.left=y+"px",-1!=e.dataTransfer.types.indexOf("wptb-moving-mode")){var v=document.getElementsByClassName("wptb-moving-mode")[0];i==v?(d.classList.add("wptb-moving-into-same-elem"),c.classList.add("wptb-moving-into-same-elem")):(d.classList.remove("wptb-moving-into-same-elem"),c.classList.remove("wptb-moving-into-same-elem"))}if(d.getDOMParentElement=function(){return i},d.style.display="block",c.style.display="block","td"!=i.nodeName.toLowerCase()){var w=null==e.offsetY?e.layerY:e.offsetY;f=Number(g.top)-Number(11),d.dataset.text="Abowe Element",b/2<w&&(f=Number(g.top)+b-1,d.dataset.text="Below Element")}else d.dataset.text="Drop Here",f=Number(g.top)+b/2-5;d.style.top=f+"px",c.style.top=g.top+"px",c.style.left=g.left+"px",wptbDropBorderMarkerTop=c.querySelector(".wptb-drop-border-marker-top"),wptbDropBorderMarkerTop.style.width=Number(i.offsetWidth)-Number(1)+"px",wptbDropBorderMarkerRight=c.querySelector(".wptb-drop-border-marker-right"),wptbDropBorderMarkerRight.style.height=Number(g.bottom)-Number(g.top)-1+"px",wptbDropBorderMarkerRight.style.left=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom=c.querySelector(".wptb-drop-border-marker-bottom"),wptbDropBorderMarkerBottom.style.width=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom.style.top=wptbDropBorderMarkerRight.style.height,wptbDropBorderMarkerLeft=c.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_ElementOptions=function(e,t,n){var a,r=e.getDOMElement();prop=document.querySelector(".wptb-"+e.kind+"-options-prototype").cloneNode(!0),prop.classList.remove("wptb-"+e.kind+"-options-prototype"),a="wptb-options-"+e.kind+"-"+t;for(var l=prop.getElementsByClassName("wptb-element-property"),o=0;o<l.length;o++)l[o].dataset.element=a;if(prop.classList.add(a),document.getElementById("element-options-group").appendChild(prop),n)if("button"==e.kind){var s=document.getElementsByClassName("wptb-element-"+n)[0],i=void 0,d=void 0,c=void 0,m=void 0;if(s&&(m=s.className.match(/wptb-size-([a-z]+)/i)),m&&Array.isArray(m)){var p=prop.getElementsByClassName("wptb-btn-size-btn");for(o=0;o<p.length;o++)p[o].classList.remove("selected"),p[o].innerHTML==m[1]&&p[o].classList.add("selected")}if(s&&(i=s.getElementsByClassName("wptb-button-wrapper"),d=s.getElementsByTagName("a"),c=s.getElementsByClassName("wptb-button")),i){var u=i[0].style.justifyContent,b=prop.querySelector('select[data-type="button-alignment"]').getElementsByTagName("option"),g=void 0;"flex-start"==u?g="left":"center"!=u&&u?"flex-end"==u&&(g="right"):g="center";for(var y=0;y<b.length;y++)b[y].value==g&&(b[y].selected=!0)}if(0<d.length){var f=d[0].getAttribute("href"),v=d[0].getAttribute("target"),w=d[0].getAttribute("id"),h=prop.querySelector('input[data-type="button-link"]'),B=prop.querySelector('input[data-type="button-link-target"]'),E=B.getAttribute("id"),T=B.parentNode.getElementsByTagName("label")[0],C=prop.querySelector('input[data-type="button-id"]');E=E+"-"+n.split("-")[1],B.setAttribute("id",E),T.setAttribute("for",E),h.value=f,v&&"_blank"==v&&(B.checked=!0),C.value=w}if(c){var N=c[0].style.color,S=c[0].style.backgroundColor,x=prop.querySelector('input[data-type="button-text-color"]'),I=prop.querySelector('input[data-type="button-color"]');x.value=WPTB_Helper.rgbToHex(N),I.value=WPTB_Helper.rgbToHex(S)}}else if("image"==e.kind){var _=document.getElementsByClassName("wptb-element-"+n);if(0<_.length){var k=_[0].getElementsByTagName("a");if(0<k.length){var L=k[0];if(L){L.onclick=function(e){e.preventDefault()};for(var A=L.style.textAlign,P=prop.querySelector('select[data-type="image-alignment"]').getElementsByTagName("option"),W=0;W<P.length;W++)P[W].value==A&&(P[W].selected=!0);var M=L.getAttribute("href"),D=prop.querySelector('input[data-type="image-link"]');M&&(D.value=M);var q=L.getAttribute("target"),H=prop.querySelector('input[data-type="image-link-target"]'),O=H.getAttribute("id"),R=H.parentNode.getElementsByTagName("label")[0];O=O+"-"+n.split("-")[1],H.setAttribute("id",O),R.setAttribute("for",O),q&&"_blank"==q&&(H.checked=!0);var z=L.getElementsByTagName("img");if(0<z.length){var j=z[0].style.width;if(j){var Q=prop.querySelector('input[type="range"][data-type="image-size"]'),F=prop.querySelector('input[type="number"][data-type="image-size"]');Q.value=parseInt(j),F.value=parseInt(j)}var G=z[0].getAttribute("alt");prop.querySelector('input[type="text"][data-type="alternative-text"]').value=G}}}}}else if("text"==e.kind){var J=document.getElementsByClassName("wptb-element-"+n);if(0<J.length){var Y=J[0].style.fontSize,X=J[0].style.color,K=prop.querySelector('input[type="range"][data-type="font-size"]'),U=prop.querySelector('input[type="number"][data-type="font-size"]'),$=prop.querySelector('input[type="text"][data-type="color"]');K.value=parseInt(Y),U.value=parseInt(Y),$.value=WPTB_Helper.rgbToHex(X)}}else if("list"==e.kind){var V=document.getElementsByClassName("wptb-element-"+n);if(0<V.length){var Z=V[0].querySelector("p").style.color;prop.querySelector('input[type="text"][data-type="list-text-color"]').value=WPTB_Helper.rgbToHex(Z);var ee=V[0].querySelectorAll("li");if(0<ee.length){var te=ee[0].querySelector("p").classList;if(0<te.length){var ne=prop.querySelector('select[data-type="list-class"]');if(ne){ne.value="unordered";for(var ae=ne.parentNode.nextSibling,re=0;re<10&&"1"!=ae.nodeType;re++)ae=ae.nextSibling;if(ae){var le=ae.getAttribute("id");ae.setAttribute("id",le+"-"+n),ae.style.display="flex"}var oe=prop.querySelector('select[data-type="list-style-type"]');oe&&(oe.parentNode.style.display="flex",te.contains("wptb-list-style-type-disc")?oe.value="disc":te.contains("wptb-list-style-type-circle")?oe.value="circle":te.contains("wptb-list-style-type-square")?oe.value="square":te.contains("wptb-list-style-type-none")&&(oe.value="none"))}}}var se=V[0].getElementsByClassName("wptb-list-item-content");if(0<se.length){for(var ie=[],de=0;de<se.length;de++){var ce=se[de].querySelector("p");ce&&(ce.style.textAlign?ie.push(ce.style.textAlign):ie.push("left"))}var me=0,pe=0,ue=0;if(0<ie.length)for(var be=0;be<ie.length;be++)ie[be]&&("left"==ie[be]?me++:"center"==ie[be]?pe++:"right"==ie[be]&&ue++);var ge=prop.querySelector('select[data-type="list-alignment"]'),ye=Math.max(me,pe,ue);me==ye?ge.value="left":pe==ye?ge.value="center":ue==ye&&(ge.value="right")}}}if(r.onclick=function(){var e=this.className.match(/wptb-element-((.+-)\d+)/i),t=".wptb-"+e[2]+"options.wptb-options-"+e[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";for(var n=document.getElementById("element-options-group").childNodes,a=0;a<n.length;a++)n[a].style&&(n[a].style.display="none");document.querySelector(t).style.display="block"},"button"==e.kind){var fe=prop.getElementsByClassName("wptb-btn-size-btn");for(o=0;o<fe.length;o++)fe[o].onclick=function(){var e=this.innerHTML,t=this.dataset.element.match(/wptb-options-(.+)-(\d+)/i),n=t[1],a=t[2],r=document.getElementsByClassName("wptb-element-"+n+"-"+a)[0];r.classList.remove("wptb-size-S"),r.classList.remove("wptb-size-M"),r.classList.remove("wptb-size-L"),r.classList.remove("wptb-size-XL"),r.classList.add("wptb-size-"+e);for(var l=this.parentNode.getElementsByClassName("wptb-btn-size-btn"),o=0;o<l.length;o++)l[o].classList.remove("selected");this.classList.add("selected")}}var ve=prop.getElementsByClassName("wptb-element-property");for(o=0;o<ve.length;o++){if(ve[o].classList.contains("wptb-color-picker")&&jQuery(ve[o]).wpColorPicker({change:function(e,t){var n,a,r,l=e.target;if(a=(n=l.dataset.element.match(/wptb-options-(.+)-(\d+)/i))[1],r=n[2],affectedEl=document.getElementsByClassName("wptb-element-"+a+"-"+r)[0],"button"==a)"button-text-color"==l.dataset.type?affectedEl.getElementsByClassName("wptb-button")[0].style.color=t.color.toString():affectedEl.getElementsByClassName("wptb-button")[0].style.backgroundColor=t.color.toString();else if("list"==a){var o=affectedEl.querySelectorAll("p");if(0<o.length)for(var s=0;s<o.length;s++)o[s].style.color=t.color.toString()}else affectedEl.style.color=t.color.toString()}}),"font-size"===ve[o].dataset.type)ve[o].parentNode.parentNode.getElementsByClassName("wptb-text-font-size-slider")[0].oninput=function(){this.parentNode.parentNode.getElementsByClassName("wptb-text-font-size-number")[0].value=this.value,this.parentNode.parentNode.getElementsByClassName("wptb-text-font-size-number")[0].onchange()};if("image-size"===ve[o].dataset.type)ve[o].parentNode.parentNode.getElementsByClassName("wptb-image-size-slider")[0].oninput=function(){this.parentNode.parentNode.getElementsByClassName("wptb-image-width-number")[0].value=this.value,this.parentNode.parentNode.getElementsByClassName("wptb-image-width-number")[0].onchange()};ve[o].onchange=function(e){var t=this.dataset.element.match(/wptb-options-(.+)-(\d+)/i),n=t[1],a=t[2],r=document.getElementsByClassName("wptb-element-"+n+"-"+a)[0],l=this.value;switch(this.dataset.type){case"src":r.getElementsByTagName("img")[0].src=this.value;break;case"alternative-text":r.getElementsByTagName("img")[0].alt=this.value;break;case"image-link":r.getElementsByTagName("a")[0].href=WPTB_Helper.linkHttpCheckChange(this.value);break;case"image-link-target":1==this.checked?r.getElementsByTagName("a")[0].target="_blank":r.getElementsByTagName("a")[0].target="_self";break;case"image-link-nofollow":1==this.checked?r.getElementsByTagName("a")[0].rel="nofollow":r.getElementsByTagName("a")[0].removeAttribute("rel");break;case"image-size":r.getElementsByTagName("img")[0].style.width=this.value+"%",r.getElementsByTagName("img")[0].style.height="auto",this.parentNode.parentNode.getElementsByClassName("wptb-image-size-slider")[0].value=this.value;break;case"image-alignment":r.getElementsByTagName("img")[0].parentNode.style.textAlign=this.value;break;case"font-size":r.style.fontSize=l+"px";break;case"button-alignment":var o="";o="left"==this.value?"start":"right"==this.value?"flex-end":"center",r.getElementsByClassName("wptb-button-wrapper")[0].style.justifyContent=o;break;case"button-link":this.value?r.getElementsByTagName("a")[0].href=WPTB_Helper.linkHttpCheckChange(this.value):r.getElementsByTagName("a")[0].removeAttribute("href");break;case"button-link-target":1==this.checked?r.getElementsByTagName("a")[0].target="_blank":r.getElementsByTagName("a")[0].target="_self";break;case"button-link-nofollow":1==this.checked?r.getElementsByTagName("a")[0].rel="nofollow":r.getElementsByTagName("a")[0].removeAttribute("rel");break;case"button-id":this.value?r.getElementsByTagName("a")[0].id=this.value:r.getElementsByTagName("a")[0].removeAttribute("id");case"button-color":break;case"list-alignment":for(var s=r.querySelectorAll("li"),i=0;i<s.length;i++){var d=s[i].querySelector("p");d&&(d.style.textAlign=this.value)}break;case"list-class":var c=e.target.parentNode.parentNode.querySelector("[data-type=list-style-type]").parentNode,m=c.parentNode;if("unordered"==l){c.style.display="flex",m.querySelector(".wptb-list-icon-select-label").style.display="flex";var p=r.querySelectorAll("li");for(i=0;i<p.length;i++){var u=p[i].querySelector("p");u.removeAttribute("class"),u.classList.add("wptb-list-style-type-disc")}m.querySelector("[data-type=list-style-type]").value="disc"}else{c.style.display="none",m.querySelector(".wptb-list-icon-select-label").style.display="none";var b=r.querySelectorAll("li");for(i=0;i<b.length;i++){b[i].querySelector("p").removeAttribute("class")}}break;case"list-style-type":for(b=r.querySelectorAll("li"),i=0;i<b.length;i++){var g=b[i].querySelector("p");g.removeAttribute("class"),g.classList.add("wptb-list-style-type-"+l.toLowerCase())}}}}},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):""},getDragImageCustom:function(e){var t=location.protocol+"//"+location.hostname,n=document.createElement("img");return n.src=t+"/wp-content/plugins/wp-table-builder/inc/admin/views/builder/icons/"+e+".png",n},dragImagesArr:function(){return{text:WPTB_Helper.getDragImageCustom("text"),image:WPTB_Helper.getDragImageCustom("image"),button:WPTB_Helper.getDragImageCustom("button"),list:WPTB_Helper.getDragImageCustom("list")}},listItemsRecalculateIndex:function(e){var t=e.querySelectorAll("p");if(0<t.length)for(var n=0;n<t.length;n++)t[n].dataset.listStyleTypeIndex=Number(n)+1+"."},listItemsTinyMceInit:function(e){tinyMCE.init({target:e,inline:!0,plugins:"link, paste",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",paste_as_text:!0,toolbar:"bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify",setup:function(e){e.on("keydown",function(e){var t=e.target.parentNode;if(13==e.keyCode){e.preventDefault();var n=e.target.innerHTML,a=new WPTB_ListItem(n,t,!0);t.parentNode.insertBefore(a.getDOMElement(),t),WPTB_Helper.listItemsTinyMceInit(a.getDOMElement().firstChild),e.target.querySelector("p").innerText="New List Item",WPTB_Helper.listItemsRecalculateIndex(t.parentNode)}else if("8"==e.keyCode||"46"==e.keyCode){var r=e.target.querySelector("p").innerHTML.replace(/<[^>]+>/g,"");if(""==(r=(r=r.replace(/\s+/g," ").trim()).replace(/&nbsp;/g,"").trim()))e.preventDefault(),e.target.querySelector("p").innerText="\n";else{var l=WPTB_Helper.getSelectionText();(l=(l=l.replace(/\s+/g," ").trim()).replace(/&nbsp;/g,"").trim())==r&&(e.preventDefault(),e.target.querySelector("p").innerText="\n")}}}),e.on("keyup",function(e){})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}})},buttonsTinyMceInit:function(e){tinyMCE.init({target:e,inline:!0,plugins:"link",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",toolbar:"bold italic strikethrough",setup:function(e){e.on("keydown",function(e){13==e.keyCode&&e.preventDefault()})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}})},linkHttpCheckChange:function(e){if(e){if(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))return e;var t=e.split("/"),n=void 0;return Array.isArray(t)&&0<t.length&&(n=t[t.length-1]),document.location.protocol+"//"+n}return""},dataTitleColumnSet:function(e){for(var t=e.rows,n=t[0],a=getComputedStyle(n),r=n.children,l={},o=0;o<r.length;o++){for(var s=r[o].children,i=0;i<s.length;i++){var d=s[i];if(d.classList.contains("wptb-ph-element")){d.getAttribute("style");if("text"==d.className.match(/wptb-element-(.+)-(\d+)/i)[1]){var c=d.querySelector("p"),m=c.textContent,p=c.style.textAlign;l[r[o].dataset.xIndex]=[m,d.style.fontSize,d.style.color,a.backgroundColor,p];break}}}l[r[o].dataset.xIndex]||(l[r[o].dataset.xIndex]=["","","",a.backgroundColor,""])}for(var u=1;u<t.length;u++)for(var b=t[u].children,g=0;g<b.length;g++)l[b[g].dataset.xIndex]?(b[g].dataset.titleColumn=l[b[g].dataset.xIndex][0],b[g].dataset.titleColumnFontSize=l[b[g].dataset.xIndex][1],b[g].dataset.titleColumnColor=l[b[g].dataset.xIndex][2],b[g].dataset.titleBackgroundColor=l[b[g].dataset.xIndex][3],b[g].dataset.titleAlign=l[b[g].dataset.xIndex][4]):(b[g].dataset.titleColumn="",b[g].dataset.titleColumnFontSize="",b[g].dataset.titleColumnColor="",b[g].dataset.titleBackgroundColor="",b[g].dataset.titleAlign="")},findAncestor:function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e},getSelectionText:function(){return window.getSelection?window.getSelection().toString():document.selection.createRange().text},settingsPanelClear:function(){document.getElementById("wptb-top-row-as-header").checked=!1,document.getElementById("wptb-table-border-slider").value=0,document.getElementById("wptb-table-border-number").value=0,document.getElementById("wptb-inner-border-check").checked=!1,document.getElementById("wptb-apply-inner-border").classList.remove("visible"),document.getElementById("wptb-table-inner-border-slider").value=1,document.getElementById("wptb-table-inner-border-number").value=1,WPTB_Helper.wpColorPickerClear("wptb-table-border-color"),WPTB_Helper.wpColorPickerClear("wptb-table-header-bg"),WPTB_Helper.wpColorPickerClear("wptb-even-row-bg"),WPTB_Helper.wpColorPickerClear("wptb-odd-row-bg"),document.getElementById("wptb-table-cell-slider").value=15,document.getElementById("wptb-table-cell-number").value=15},wpColorPickerClear:function(e){var t=document.getElementById(e),n=WPTB_Helper.findAncestor(t,"wp-picker-container"),a=n.parentNode;a.removeChild(n);var r=document.createElement("input");r.setAttribute("id",e),r.value="",a.appendChild(r)},detectMode:function(){var e=window.location.href,t=new RegExp("[?&]table(=([^&#]*)|&|#|$)").exec(e);return!!t&&(t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"")}},WPTB_Image=function(e,t){var n=void 0,a=void 0,r=!1;if(null==t){n=document.createElement("div");var l=document.createElement("a"),o=document.createElement("img");l.style.display="inline-block",l.appendChild(o),n.appendChild(l),l.onclick=function(e){e.preventDefault()},file_frame=wp.media.frames.file_frame=wp.media({title:"Select a image to upload",button:{text:"Use this image"},multiple:!1}),file_frame.on("select",function(){attachment=file_frame.state().get("selection").first().toJSON(),o.src=attachment.url}),null==e?file_frame.open():o.src=e}else{(n=t.cloneNode(!0)).getElementsByTagName("a")[0].onclick=function(e){e.preventDefault()};var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(a=s[1],r=!0)}return this.kind="image",this.getDOMElement=function(){return n},applyGenericItemSettings(this,a,r),this},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<10&&columnsInput.value++},rowsDecrementButton.onclick=function(){1<rowsInput.value&&rowsInput.value--},rowsIncrementButton.onclick=function(){rowsInput.value<10&&rowsInput.value++},document.getElementById("wptb-generate-table").onclick=function(){var e=document.getElementById("wptb-columns-number").value,t=document.getElementById("wptb-rows-number").value;WPTB_Table(e,t)}},WPTB_LeftPanel=function(){var e,t,l=document.getElementsByClassName("wptb-preview-table")[0],n=document.getElementsByClassName("wptb-element");function a(e,t){if(!(3<t)&&l){var n=l.getElementsByTagName("tr");if(n.length>t){var a=n[t].style.backgroundColor,r=document.getElementById(e);r&&a&&(r.value=WPTB_Helper.rgbToHex(a))}}}function r(e){for(var t=l.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.borderWidth=document.querySelector("#wptb-table-inner-border-number").value+"px",t[n].style.borderStyle="solid"}function o(e){for(var t=l.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.padding=e+"px"}function s(e){l.style.borderWidth=e+"px",l.style.borderStyle="solid"}function i(e,t,n){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;e=String(e),n<e&&(this.value=n)}}a("wptb-even-row-bg",1),jQuery("#wptb-even-row-bg").wpColorPicker({change:function(e,t){for(var n=l.getElementsByTagName("tr"),a=1;a<n.length;a+=2)n[a].style.backgroundColor=t.color.toString()},clear:function(){for(var e=l.getElementsByTagName("tr"),t=1;t<e.length;t+=2){e[t].style.backgroundColor="";for(var n=e[t].getElementsByTagName("td"),a=0;a<n.length;a++)n[a].style.backgroundColor=""}}}),a("wptb-odd-row-bg",2),jQuery("#wptb-odd-row-bg").wpColorPicker({change:function(e,t){for(var n=l.getElementsByTagName("tr"),a=2;a<n.length;a+=2)n[a].style.backgroundColor=t.color.toString()},clear:function(){for(var e=l.getElementsByTagName("tr"),t=2;t<e.length;t+=2){e[t].style.backgroundColor="";for(var n=e[t].getElementsByTagName("td"),a=0;a<n.length;a++)n[a].style.backgroundColor=""}}}),a("wptb-table-header-bg",0),jQuery("#wptb-table-header-bg").wpColorPicker({change:function(e,t){l.getElementsByTagName("tr")[0].style.backgroundColor=t.color.toString()},clear:function(){var e=l.getElementsByTagName("tr")[0];e.style.backgroundColor="";for(var t=e.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.backgroundColor=""}}),e=l,t=document.getElementById("wptb-top-row-as-header"),e&&e.classList.contains("wptb-table-preview-head")?t.checked=!0:t.checked=!1,function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].style.borderColor;if(t){var n=document.getElementById("wptb-table-border-color");n&&(n.value=WPTB_Helper.rgbToHex(t))}var a=e[0].style.borderWidth;if(a){var r=document.getElementById("wptb-table-border-slider"),l=document.getElementById("wptb-table-border-number");r&&(r.value=parseInt(a)),l&&(l.value=parseInt(a))}var o=e[0].querySelector("td").style.borderWidth;if(o){var s=document.getElementById("wptb-inner-border-check"),i=document.getElementById("wptb-apply-inner-border");if(o&&0<parseInt(o)){if(s&&(s.checked=!0,i)){i.classList.add("visible");var d=document.getElementById("wptb-table-inner-border-slider"),c=document.getElementById("wptb-table-inner-border-number");d.value=parseInt(o),c.value=parseInt(o)}}else s.checked=!1}(a&&0<parseInt(a)||o&&0<parseInt(o))&&(document.getElementById("wptb-table-border-color-set-area").style.display="")}}(),jQuery("#wptb-table-border-color").wpColorPicker({change:function(e,t){var n=l.getElementsByTagName("td");l.style.border=document.querySelector("#wptb-table-border-number").value+"px solid "+t.color.toString();for(var a=0;a<n.length;a++){var r=document.querySelector("#wptb-table-inner-border-number").value;document.getElementById("wptb-inner-border-check").checked&&(n[a].style.border=(0!=r?r:1)+"px solid "+t.color.toString())}},clear:function(){var e=l.getElementsByTagName("td");l.style.borderColor="";for(var t=0;t<e.length;t++)e[t].style.borderColor=""}}),function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].querySelector("td");if(t){var n=t.style.padding;if(n){var a=document.getElementById("wptb-table-cell-slider"),r=document.getElementById("wptb-table-cell-number");a&&(a.value=parseInt(n)),r&&(r.value=parseInt(n))}}}}(),i(document.getElementById("wptb-table-border-number"),1,50),i(document.getElementById("wptb-table-inner-border-number"),1,50),i(document.getElementById("wptb-table-cell-number"),1,50),i(document.getElementById("wptb-text-font-size-number"),1,50),i(document.getElementById("wptb-image-width-number"),2,100),document.getElementById("wptb-table-cell-slider").oninput=function(){document.getElementById("wptb-table-cell-number").value=this.value,o(this.value)},document.getElementById("wptb-table-cell-number").onchange=function(){document.getElementById("wptb-table-cell-slider").value=this.value,o(this.value)},document.getElementById("wptb-table-border-slider").oninput=function(){document.getElementById("wptb-table-border-number").value=this.value,s(this.value);var e=document.getElementById("wptb-inner-border-check").checked,t=document.getElementById("wptb-table-border-color-set-area");0==this.value&&0==e?t.style.display="none":t.style.display=""},document.getElementById("wptb-table-border-number").onchange=function(){document.getElementById("wptb-table-border-slider").value=this.value,s(this.value)},document.getElementById("wptb-table-inner-border-slider").oninput=function(){document.getElementById("wptb-table-inner-border-number").value=this.value,r(this.value)},document.getElementById("wptb-table-inner-border-number").onchange=function(){document.getElementById("wptb-table-inner-border-slider").value=this.value,r(this.value)},document.getElementById("wptb-inner-border-check").onchange=function(){if(l){var e=this.checked?"checked":"unchecked";!function(e){var t=null!=document.querySelector("#wptb-table-border-color").value?document.querySelector("#wptb-table-border-color").value:"rgb(0,0,0)";0!=document.querySelector("#wptb-table-inner-border-slider").value&&0!=document.querySelector("#wptb-table-inner-border-number").value||(document.querySelector("#wptb-table-inner-border-slider").value=1,document.querySelector("#wptb-table-inner-border-number").value=1);var n=document.querySelector("#wptb-table-inner-border-slider").value+"px",a=document.getElementsByClassName("wptb-preview-table");if(0<a.length)if("checked"==e){document.getElementById("wptb-apply-inner-border").style.marginBottom="0px";for(var r=a[0].getElementsByTagName("td"),l=0;l<r.length;l++)r[l].style.border=n+" solid "+t;document.getElementById("wptb-apply-inner-border").classList.add("visible")}else for(document.getElementById("wptb-apply-inner-border").classList.remove("visible"),r=a[0].getElementsByTagName("td"),l=0;l<r.length;l++)r[l].style.border="0px solid "+t}(e);var t=document.getElementById("wptb-table-border-slider").value,n=document.getElementById("wptb-table-border-color-set-area");n.style.display="unchecked"==e&&0==t?"none":""}},document.getElementById("wptb-top-row-as-header").onchange=function(){!function(e,t){if(t.checked)WPTB_Helper.dataTitleColumnSet(e),e.classList.add("wptb-table-preview-head"),e.rows[0].classList.add("wptb-table-head");else{var n=e.rows;e.classList.remove("wptb-table-preview-head"),n[0].classList.remove("wptb-table-head");for(var a=1;a<n.length;a++)for(var r=n[a].children,l=0;l<r.length;l++)r[l].removeAttribute("data-title-column")}}(l,this)};for(var d=0;d<n.length;d++)n[d].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-activate-cell-management-mode").onclick=l.toggleTableEditMode,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].addEventListener("click",function(e){if(!(e.target.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.target,"wptb-ph-element")||e.target.classList.contains("wptb-fixed-toolbar")||WPTB_Helper.findAncestor(e.target,"wptb-fixed-toolbar"))){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 t=document.getElementById("wpcd_fixed_toolbar");t.hasAttribute("data-toolbar-active-id")&&document.getElementById(t.getAttribute("data-toolbar-active-id")).classList.remove("toolbar-active")}},!1)},WPTB_List=function(e,t){var n,a=document.createElement("ul"),r=document.createElement("div"),l=void 0,o=!1;if(r.classList.add("wptb-list-item-container"),this.kind="list",""===e);else if(e){var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(l=s[1],o=!0);for(d=0;d<e.length;d++){var i=t.querySelector("li");n=new WPTB_ListItem(e[d],i,!0),a.appendChild(n.getDOMElement())}}else for(var d=0;d<3;d++)n=new WPTB_ListItem("<p>List Item "+(d+1)+"</p>"),a.appendChild(n.getDOMElement());return r.appendChild(a),this.getDOMElement=function(){return r},applyGenericItemSettings(this,l,o),WPTB_Helper.listItemsRecalculateIndex(a),this},WPTB_ListItem=function r(e,t,n){var a=void 0;if(null==t||t&&n){null==e&&(e="New List Item");var l=document.createElement("li");if((s=document.createElement("div")).classList.add("wptb-list-item-content"),t){var o=t.getAttribute("style");o&&l.setAttribute("style",o)}l.appendChild(s),s.innerHTML=e,s.onkeyup=window.listItemKeyListener,a=!0}else{var s;(s=(l=t).getElementsByClassName("wptb-list-item-content")[0]).onkeyup=window.listItemKeyListener,a=!1}if(l.onmouseenter=function(e){var t=document.createElement("span"),n=document.createElement("span"),a=document.createElement("span");a.classList.add("wptb-actions"),t.classList.add("dashicons","dashicons-trash","wptb-delete-action"),n.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),this.classList.add("wptb-directlyhovered"),t.onclick=function(){var e=this.parentNode,t=this.parentNode.parentNode,n=t.parentNode;t.removeChild(e),n.removeChild(t),WPTB_Helper.listItemsRecalculateIndex(n)},n.onclick=function(e){var t=e.target.parentNode.parentNode,n=t.querySelector(".wptb-list-item-content").innerHTML,a=new r(n,t,!0);t.parentNode.insertBefore(a.getDOMElement(),l),WPTB_Helper.listItemsTinyMceInit(a.getDOMElement().firstChild),setTimeout(function(){s.innerHTML=n,WPTB_Helper.listItemsRecalculateIndex(t.parentNode)},5)},a.append(n,t),this.appendChild(a)},l.onmouseleave=function(e){this.removeAttribute("class");for(var t=0;e.target.querySelector(".wptb-actions")&&t<5;)e.target.querySelector(".wptb-actions").remove(),t++},this.getDOMElement=function(){return l},a)return this},MultipleSelect=function(){var r=[],n=!1;return this.activateMultipleSelectMode=function(){r=[];for(var e=document.getElementsByClassName("wptb-preview-table")[0].getElementsByTagName("td"),t=0;t<e.length;t++)e[t].classList.remove("wptb-highlighted");n=!0},this.deactivateMultipleSelectMode=function(){n=!1},this.isActivated=function(){return n},this.pushSelectedCell=function(e){n&&(r.push(e),e.classList.add("wptb-highlighted"))},this.selectedCells=function(){return r},this.flushSelectedCells=function(){r=[]},this.getFirst=function(){for(var e,t=1e3,n=1e3,a=r.length-1;0<=a;a--)t>=r[a].dataset.xIndex&&n>=r[a].dataset.yIndex&&(e=r[a],t=r[a].dataset.xIndex,n=r[a].dataset.yIndex);return e},this.getLast=function(){for(var e,t=-1,n=-1,a=r.length-1;0<=a;a--)t<=r[a].dataset.xIndex&&n<=r[a].dataset.yIndex&&(e=r[a],t=r[a].dataset.xIndex,n=r[a].dataset.yIndex);return e},this.removeAllButFirst=function(){for(var e=this.getFirst(),t=1;t<r.length;t++)r[t].classList.add("wptb-fused-cell-"+e.dataset.xIndex+"-"+e.dataset.yIndex)},this};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Parser=function(e){var t=document.createElement("div");t.innerHTML=e;for(var n=t.children[0],a=[].concat(_toConsumableArray(n.querySelectorAll(".wptb-column-title-mobile-container"))),r=0;r<a.length;r++){a[r].parentNode.removeChild(a[r])}for(var l=n.querySelectorAll("td"),o=0;o<l.length;o++)l[o].classList.add("wptb-droppable"),l[o].classList.remove("wptb-column-title-mobile-not-elements");return n},WPTB_Parser2=function(e){if(Array.isArray(e)){var t=void 0;if(1==e.length)return t.appendChild(document.createTextNode(e[0]));if(0 in e){var n=e[0];if(t=document.createElement(n),1 in e&&Array.isArray(e[1]))for(var a=e[1],r=0;r<a.length;r++)Array.isArray(a[r])&&t.setAttribute(a[r][0],a[r][1]);if(2 in e)if(Array.isArray(e[2]))for(var l=0;l<e[2].length;l++)"string"!=typeof e[2][l]||"p"!=n.toLowerCase()?WPTB_Parser(e[2][l])&&t.appendChild(WPTB_Parser(e[2][l])):t.appendChild(document.createTextNode(e[2][l]));else"string"==typeof e[2]&&t.appendChild(document.createTextNode(e[2]))}return t}return!1},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(){var e=document.querySelector(".wptb-drop-handle"),t=document.querySelector(".wptb-drop-border-marker");(e||t)&&(e.style.display="none",t.style.display="none")};var n=document.getElementsByClassName("wptb-shortcode-popup-window-modal")[0];document.getElementsByClassName("wptb-embed-btn")[0].onclick=function(){this.classList.contains("wptb-embed-disable")||n.classList.add("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-shortcode-popup-dark-area")[0].onclick=function(){n.classList.remove("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-shortcode-popup-window-close-icon")[0].onclick=function(){n.classList.remove("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-save-btn")[0].onclick=function(){var e=document.querySelector(".wptb-edit-bar");e&&e.classList.contains("visible")&&document.getElementsByClassName("wptb-preview-table")[0].toggleTableEditMode();var n=new XMLHttpRequest,t=(wptb_admin_object?wptb_admin_object.ajaxurl:ajaxurl)+"?action=save_table",a=document.getElementById("wptb-setup-name").value.trim(),r=void 0,l=document.getElementsByClassName("wptb-preview-table");if(l=0<l.length?(l=WPTB_Stringifier(l[0])).outerHTML:"",""===a||""===l){var o="";return""===a&&(o+="You must assign a name to the table before saving it.</br>"),""===l&&(o+="Table wasn't created"),(r=document.getElementById("wptb-messaging-area")).innerHTML='<div class="wptb-error wptb-message">Error: '+o+"</div>",r.classList.add("wptb-warning"),void setTimeout(function(){r.removeChild(r.firstChild)},4e3)}var s={title:a,content:l,security_code:wptb_admin_object.security_code};((rs=WPTB_Helper.detectMode())||(rs=document.wptbId))&&(s.id=rs),s=JSON.stringify(s),n.open("POST",t,!0),n.setRequestHeader("Content-type","application/json; charset=utf-8"),n.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(n.responseText);r=document.getElementById("wptb-messaging-area"),"saved"==t[0]?(document.wptbId=t[1],r.innerHTML='<div class="wptb-success wptb-message">Table "'+a+'" was successfully saved.</div>',document.getElementsByClassName("wptb-embed-btn")[0].classList.remove("wptb-embed-disable"),document.getElementById("wptb-embed-shortcode").value="[wptb id="+t[1]+"]"):"edited"==t[0]?r.innerHTML='<div class="wptb-success wptb-message">Table "'+a+'" was successfully updated.</div>':r.innerHTML='<div class="wptb-error wptb-message">Safety problems</div>',r.classList.add("wptb-success"),setTimeout(function(){r.removeChild(r.firstChild)},4e3)}},n.send(s)}},WPTB_Space=function s(e){var t=void 0;if(e?t=e:(t=document.createElement("div")).classList.add("wptb-space-between"),t.ondragenter=function(){this.classList.add("visible")},t.ondragover=function(e){e.preventDefault()},t.ondragleave=function(){this.classList.remove("visible")},t.ondrop=function(e){e.stopPropagation();for(var t,n,a,r,l=e.target.nextSibling,o=e.target;!o.classList.contains("wptb-droppable");)o=o.parentNode;e.dataTransfer.getData("wptbElement")?(t=(r=e.dataTransfer.getData("wptbElement")).includes("list")?new WPTB_List:r.includes("image")?new WPTB_Image:r.includes("text")?new WPTB_Text:r.includes("button")?new WPTB_Button:void 0,this.classList.remove("visible"),null==l?(o.appendChild(t.getDOMElement()),o.appendChild(new s)):(o.insertBefore(t.getDOMElement(),l),o.insertBefore(new s,l))):(alert(e.dataTransfer.getData("node")),n=(t=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).nextSibling,a=t.parentNode,null!=n&&a.removeChild(n),null==l?(o.appendChild(t),o.appendChild(new s)):(o.insertBefore(t,l),o.insertBefore(new s,l))),this.classList.remove("visible")},!e)return t},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.dataset.reconstraction=1;var n=t.getElementsByTagName("td");if(0<n.length)for(var a=0;a<n.length;a++){for(var r=0;r<n.length;r++)if(1==t.dataset.reconstraction&&1<n[r].colSpan||1<n[r].rowSpan){t.dataset.reconstraction=0;break}e.querySelector("wptb-table-preview-head")&&n[a].removeAttribute("data-x-index"),n[a].removeAttribute("data-y-index"),n[a].removeAttribute("draggable"),n[a].classList.remove("wptb-droppable");var l=n[a].getElementsByClassName("wptb-ph-element");if(0<l.length)for(var o=0;o<l.length;o++){l[o].classList.remove("wptb-directlyhovered");var s=l[o].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=l[o].querySelectorAll("[data-mce-style]");if(0<d.length)for(var c=0;c<d.length;c++)d[c].removeAttribute("data-mce-style");var m=l[o].querySelectorAll("[contenteditable]");if(0<m.length)for(var p=0;p<m.length;p++)m[p].removeAttribute("contenteditable");var u=l[o].querySelectorAll("[spellcheck]");if(0<u.length)for(var b=0;b<u.length;b++)u[b].removeAttribute("spellcheck");var g=l[o].querySelectorAll("[id^=mce_]");if(0<g.length)for(var y=0;y<g.length;y++)g[y].removeAttribute("id");for(var f=l[o].querySelectorAll(".wptb-actions"),v=f.length;0<v;)f[0].parentNode.removeChild(f[0]),v--}if(n[a].hasAttribute("data-title-column")){var w=document.createElement("div"),h=document.createElement("div");w.classList.add("wptb-column-title-mobile-container"),h.classList.add("wptb-column-title-mobile"),h.dataset.titleColumn=n[a].dataset.titleColumn,h.setAttribute("style","font-size:"+n[a].dataset.titleColumnFontSize+"; \n color:"+n[a].dataset.titleColumnColor+"; background-color:"+n[a].dataset.titleBackgroundColor+"; text-align:"+n[a].dataset.titleAlign+";"),h.style.padding=n[a].style.padding,0==n[a].children.length&&n[a].classList.add("wptb-column-title-mobile-not-elements"),w.appendChild(h),n[a].insertBefore(w,n[a].firstChild)}}return t}};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Stringifier2=function(e){1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(null==e)return"";if(null==e.tagName&&3==e.nodeType)return e.nodeValue;var t=[],n=void 0,a=!1,r=[].concat(_toConsumableArray(e.attributes)),l=[],o=[];if((e.parentNode.classList.contains("wptb-list-item-content")||e.parentNode.classList.contains("mce-content-body"))&&"p"==e.tagName.toLowerCase()?(n=e.childNodes,a=!0):n=0<e.children.length?e.children:e.childNodes,0<r.length)for(var s=0;s<r.length;s++)l[s]=[r[s].name,r[s].value];else l="";if(0<n.length)for(var i=0;i<n.length;i++){var d=WPTB_Stringifier(n[i]);Array.isArray(d)||a?o[i]=d:"string"==typeof d&&d&&(o=d)}else o="";return t.push(e.tagName.toLowerCase(),l,o),t},_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},array=[],WPTB_Table=function(e,t){var h,n,a,f,r=document.getElementsByClassName("wptb-settings-items"),B=document.getElementsByClassName("wptb-table-setup")[0],E=function(e){var t,n=this.rowSpan,a=this.colSpan,r=document.getElementsByClassName("wptb-no-cell-action"),l=document.getElementsByClassName("wptb-single-action"),o=document.getElementsByClassName("wptb-multiple-select-action"),s=N(this),i=s[0],d=s[1];if(document.select.isActivated()){if(this.className.match(/wptb-highlighted/)){this.classList.remove("wptb-highlighted");for(var c=0;c<n;c++)for(var m=0;m<a;m++)array[i+c][d+m]=0}else{this.classList.add("wptb-highlighted");for(c=0;c<n;c++)for(m=0;m<a;m++)array[i+c][d+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<r.length;c++)r[c].classList.add("visible"),r[c].removeAttribute("disabled");for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled")}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<r.length;c++)r[c].classList.remove("visible"),r[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.add("visible"),l[c].removeAttribute("disabled")}else{for(c=0;c<o.length;c++)h.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<r.length;c++)r[c].classList.remove("visible"),r[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled")}}},T=function(e){for(var t=0;t<e.length;t++){for(var n=0;n<e[t].length;n++)" "+e[t][n];"\n"}h.isSquare(e)},C=function(){for(var e=document.getElementsByClassName("wptb-no-cell-action"),t=document.getElementsByClassName("wptb-single-action"),n=document.getElementsByClassName("wptb-multiple-select-action"),a=h.getElementsByClassName("wptb-highlighted");a.length;)a[0].classList.remove("wptb-highlighted");for(var r=0;r<array.length;r++)for(var l=0;l<array[r].length;l++)array[r][l]=0;for(r=0;r<n.length;r++)n[r].classList.remove("visible"),n[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")},N=function(e){for(var t=[],n=0;n<f;n++)t[n]=0;for(n=0;n<h.rows.length;n++)for(var a=h.rows[n].getElementsByTagName("td"),r=cellPointer=0;r<f;r+=stepsToMove)if(stepsToMove=1,t[r])t[r]--;else{var l=a[cellPointer++];if(l==e)return[n,r];if(1<l.rowSpan){for(var o=0;o<l.colSpan;o++)t[r+o]=l.rowSpan-1;stepsToMove=l.colSpan}else 1<l.colSpan&&(stepsToMove=l.colSpan)}};if(jQuery("#wptb-table-header-bg").val(""),jQuery("#wptb-even-row-bg").val(""),jQuery("#wptb-odd-row-bg").val(""),jQuery("#wptb-table-border-color").val(""),jQuery("#wptb-table-inner-border-number,#wptb-table-inner-border-slider").val("0"),jQuery("#wptb-table-border-number,#wptb-table-border-slider").val("0"),jQuery("#wptb-table-padding-number,#wptb-table-padding-slider").val("15"),e||t){for(var l=0;l<r.length;l++)"wptb-apply-inner-border"!==r[l].id&&r[l].classList.add("visible");(h=document.createElement("table")).classList.add("wptb-preview-table");for(l=0;l<t;l++){(n=h.insertRow(-1)).classList.add("wptb-row");for(var g=0;g<e;g++)(a=new WPTB_Cell(E)).setCoords(l,g),n.appendChild(a.getDOMElement())}}else{var o=document.getElementsByClassName("wptb-preview-table");if(0<o.length){var s=(h=o[0]).getElementsByTagName("td");if(0<s.length)for(var i=0;i<s.length;i++)WPTB_Cell(E,s[i])}}h.toggleTableEditMode=function(){var e=document.getElementsByClassName("wptb-edit-bar"),t=document.getElementById("wptb-cell_mode_background"),n=document.getElementById("wptb-left-scroll-panel-curtain"),a=document.getElementsByClassName("wptb-preview-table");if(0<a.length&&(a=a[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"),n.classList.remove("visible"),a.classList.remove("wptb-preview-table-manage-cells");var l=a.getElementsByTagName("td");if(0<l.length)for(var o=0;o<l.length;o++)l[o].classList.remove("wptb-highlighted")}else document.select.activateMultipleSelectMode(),e[r].classList.add("visible"),t.classList.add("visible"),n.classList.add("visible"),a.classList.add("wptb-preview-table-manage-cells")},h.recalculateIndexes=function(e){for(var t=this.getElementsByTagName("tr"),n=void 0,a=0,r=[],l=document.getElementById("wptb-top-row-as-header"),o=0;o<t.length;o++){0==o?(null==e&&(t[o].style.backgroundColor=jQuery("#wptb-table-header-bg").val()),l.checked?null==e&&(this.classList.add("wptb-table-preview-head"),t[o].classList.add("wptb-table-head")):null==e&&(this.classList.remove("wptb-table-preview-head"),t[o].classList.remove("wptb-table-head"))):(o%2==0?null==e&&(t[o].style.backgroundColor=jQuery("#wptb-odd-row-bg").val()):null==e&&(t[o].style.backgroundColor=jQuery("#wptb-even-row-bg").val()),t[o].classList.remove("wptb-table-head")),r[o],n=t[o].getElementsByTagName("td"),null==r[o]&&(r[o]=[]);for(var s=0,i=0;i<n.length;i++){if(null!=r[o][i])for(var d=0;d<100;d++){if(null==r[o][s]){r[o][s]=n[i],n[i].dataset.xIndex=s;break}s++}else r[o][i]=n[i],n[i].dataset.xIndex=s;if(n[i].dataset.yIndex=o,1<n[i].colSpan)for(var c=1;c<n[i].colSpan;c++)s++,r[o][s]="tdDummy";if(1<n[i].rowSpan)for(var m=1;m<n[i].rowSpan;m++){null==r[o+m]&&(r[o+m]=[]);for(var p=0;p<n[i].colSpan;p++)r[o+m][s-n[i].colSpan+1+p]="tdDummy"}s++}a<i&&(a=i)}this.columns=a},h.addColumnEnd=function(){var e=void 0,t=document.getElementsByClassName("wptb-preview-table"),n=void 0,a=void 0;0<t.length&&(n=t[0].querySelector("td")),n&&(a=n.getAttribute("style"));for(var r=0;r<h.rows.length;r++)e=new WPTB_Cell(E),a&&e.getDOMElement().setAttribute("style",a),h.rows[r].appendChild(e.getDOMElement()),array[r].push(0);f++,h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.addColumnStart=function(){var e=void 0,t=void 0,n=document.getElementsByClassName("wptb-preview-table"),a=void 0,r=void 0;0<n.length&&(a=n[0].querySelector("td")),a&&(r=a.getAttribute("style"));for(var l=0;l<h.rows.length;l++)e=new WPTB_Cell(E),r&&e.getDOMElement().setAttribute("style",r),(t=h.rows[l].getElementsByTagName("td")[0])?h.rows[l].insertBefore(e.getDOMElement(),t):h.rows[l].appendChild(e.getDOMElement()),array[l].push(0);f++,h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.addColumnAfter=function(e){var t=h.rows,n=void 0,a=void 0,r=document.querySelector(".wptb-highlighted"),l=r.getAttribute("style"),o=null!=e&&"number"==typeof e?e:N(r)[1];if(f-o-r.colSpan+1==1)h.addColumnEnd();else{for(var s=!1,i=void 0,d=void 0,c=void 0,m=[],p=void 0,u=0;u<f;u++)m.push(0);for(u=0;u<t.length;u++){n=0,a=t[u].getElementsByTagName("td"),s=!1;for(var b=0;b<f;b+=i){if(i=1,s){d=new WPTB_Cell(E),l&&d.getDOMElement().setAttribute("style",l),p&&t[u].contains(p)?(c=p.nextSibling)?t[u].insertBefore(d.getDOMElement(),c):t[u].appendChild(d.getDOMElement()):t[u].insertBefore(d.getDOMElement(),a[0]);break}if(0<m[b])o==b&&(s=!0);else if(1<(p=a[n++]).rowSpan){i=p.colSpan;for(var g=0;g<p.colSpan;g++)m[b+g]=p.rowSpan,b+g==o&&(s=!0)}else if(1<p.colSpan){i=p.colSpan;for(g=0;g<p.colSpan;g++)b+g==o&&(s=!0)}else b==o&&(s=!0)}for(var y=0;y<f;y++)0<m[y]&&m[y]--}for(u=0;u<array.length;u++)array[u].push(0);f++,T(array),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()}},h.addColumnBefore=function(){var e=document.querySelector(".wptb-highlighted"),t=N(e)[1];0===t?h.addColumnStart():h.addColumnAfter(t-1)},h.addRowToTheEnd=function(){var e,t=h.insertRow(-1),n=void 0,a=document.getElementsByClassName("wptb-preview-table"),r=void 0,l=void 0;t.classList.add("wptb-row"),0<a.length&&(r=a[0].querySelector("td")),r&&(l=r.getAttribute("style"));for(var o=0;o<f;o++)n=new WPTB_Cell(E),l&&n.getDOMElement().setAttribute("style",l),t.appendChild(n.getDOMElement());e=Array.from(array[0]),array.push(e),T(array),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.addRowToTheStart=function(){var e,t=h.insertRow(0),n=void 0,a=document.getElementsByClassName("wptb-preview-table"),r=void 0,l=void 0;t.classList.add("wptb-row"),0<a.length&&(r=a[0].querySelector("td")),r&&(l=r.getAttribute("style"));for(var o=0;o<f;o++)n=new WPTB_Cell(E),l&&n.getDOMElement().setAttribute("style",l),t.appendChild(n.getDOMElement());e=Array.from(array[0]),array.push(e),T(array),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.addRowBefore=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),n=N(e)[0],a=void 0,r=n-1;0<=r;r--){var l=h.rows[r].children,o=l.length;if(0<o)for(var s=0;s<o;s++)if(1==l[s].rowSpan){n=r,a=!0;break}if(a)break}0===n?h.addRowToTheStart():h.addRowAfter(n,t)},h.addRowAfter=function(e,t){var n,a=void 0;if(null!=e&&"number"==typeof e||null!=t)a=e;else{var r=document.querySelector(".wptb-highlighted");t=r.getAttribute("style"),a=(e=N(r)[0])+r.rowSpan-1}var l=0;if(a<h.rows.length-1){for(var o=0;o<=a;o++){var s=h.rows[o].children,i=s.length;if(0<i)for(var d=0;d<i;d++){a<s[d].rowSpan-1+o&&s[d].rowSpan++}}var c=h.rows[a+1].children,m=c.length;if(0<m)for(var p=0;p<m;p++)l+=c[p].colSpan}else l=array[0].length;var u=h.insertRow(a+1);for(u.classList.add("wptb-row"),g=0;g<l;g++){var b=new WPTB_Cell(E);b.getDOMElement().setAttribute("style",t),u.appendChild(b.getDOMElement())}n=Array.from(array[0]),array.push(n),T(array),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.isSquare=function(e){for(var t,n,a=-1,r=-1,l=-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<r||-1==r)&&(r=d),(i<a||-1==a)&&(a=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),l<i&&(l=i));for(i=a;i<l;i++)for(d=r;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=l-a+1)*(n=o-r+1)===s&&[t,n]},h.mergeCells=function(){for(var e=h.isSquare(array),t=e[0],n=e[1],a=document.querySelector(".wptb-highlighted"),r=[].slice.call(document.getElementsByClassName("wptb-highlighted"),1),l=[],o=0;o<r.length;o++){var s=r[o].getElementsByClassName("wptb-ph-element");if(0<s.length)for(var i=s.length,d=0;d<i;d++)l.push(s[d]);r[o].parentNode.removeChild(r[o])}if(0<l.length)for(var c=0;c<l.length;c++)a.appendChild(l[c]);a.colSpan=n,a.rowSpan=t,h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.splitCell=function(){var e=document.getElementsByClassName("wptb-highlighted")[0],t=e.rowSpan,n=e.colSpan,a=e.getAttribute("style"),r=N(e)[0],l=h.rows[r],o=e.dataset.xIndex;e.rowSpan=1;for(var s=e.colSpan=1;s<n;s++){var i=new WPTB_Cell(E);i.getDOMElement().setAttribute("style",a),e.nextSibling?l.insertBefore(i.getDOMElement(),e.nextSibling):l.appendChild(i.getDOMElement())}if(1<t)for(var d=1;d<t;d++){var c=void 0,m=h.rows[r+d],p=m.children,u=p.length;if(0<u)for(var b=0;b<u;b++)if(Number(p[b].dataset.xIndex)>Number(o)){c=p[b];break}for(var g=0;g<n;g++){var y=new WPTB_Cell(E);y.getDOMElement().setAttribute("style",a),null!=c?m.insertBefore(y.getDOMElement(),c):m.appendChild(y.getDOMElement())}}h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h),C()},h.findRowspannedCells=function(e){var t,n=[];if(actualPoints=function(e){for(var t=h.rows[e].getElementsByTagName("td"),n=0,a=0;a<t.length;a++)n+=t[a].colSpan;return n}(e),actualPoints===f)return[];t=f-actualPoints;for(var a=e-1;0<=a&&t;a--){var r=h.rows[a].getElementsByTagName("td");for(a=0;a<r.length;a++)1<r[a].rowSpan&&(n.push(r[a]),t-=r[a].colSpan)}return n},h.addLackingCells=function(){for(var e=[],t=0;t<h.rows.length;t++)e.push(0);for(t=0;t<h.rows.length;t++)for(var n=h.rows[t].getElementsByTagName("td"),a=0;a<n.length;a++)if(1<n[a].rowSpan)for(var r=1;r<n[a].rowSpan;r++)e[t+r]++;for(t=0;t<h.rows.length;t++){n=h.rows[t].getElementsByTagName("td");var l=0;for(a=0;a<n.length;a++)l+=n[a].colSpan;l+=e[t],difference=f-l;for(a=0;a<difference;a++){var o=new WPTB_Cell(E);h.rows[t].appendChild(o.getDOMElement())}}},h.deleteRow=function(){var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),n=e.rowSpan,a=N(e)[0],r=void 0;null==n&&(n=1);for(var l=0;l<n;l++){var o=h.rows[a].children,s=h.rows[a+1],i=void 0,d=void 0,c=[];if(null!=s){d=(i=s.children).length;for(var m=0;m<o.length;m++)if(1<o[m].rowSpan){var p=new WPTB_Cell(E);p.getDOMElement().setAttribute("style",t),p.getDOMElement().colSpan=o[m].colSpan,p.getDOMElement().rowSpan=o[m].rowSpan-1;for(var u=void 0,b=0;b<d;b++)if(Number(i[b].dataset.xIndex)>Number(o[m].dataset.xIndex)){u=i[b];break}u?c.push([p,u]):c.push([p])}if(0<c.length)for(var g=0;g<c.length;g++)null!=c[g][1]?s.insertBefore(c[g][0].getDOMElement(),c[g][1]):s.appendChild(c[g][0].getDOMElement())}var y=h.rows;if(0<y.length)for(var f=0;f<a;f++){var v=y[f].children;if(0<v.length)for(var w=0;w<v.length;w++)v[w].rowSpan-1>=a-f&&v[w].rowSpan--}r=Array.from(array[0]),array.pop(r),T(array),h.getElementsByTagName("tbody")[0].removeChild(h.rows[a]),0==h.rows.length&&(h.toggleTableEditMode(),B.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h)}C()},h.deleteColumn=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.dataset.xIndex,n=e.colSpan,a=0;a<n;a++){for(var r=0;r<h.rows.length;r++){var l=h.rows[r].children,o=l.length;if(0<o)for(var s=o-1;0<=s;s--){if(Number(l[s].dataset.xIndex)==Number(t)){1<l[s].colSpan?l[s].colSpan--:h.rows[r].removeChild(l[s]);break}if(Number(l[s].dataset.xIndex)<Number(t)&&Number(l[s].dataset.xIndex)+Number(l[s].colSpan-1)>=t){1<l[s].colSpan&&l[s].colSpan--;break}}}for(var i=0;i<h.rows.length;i++)null!=array[i]&&array[i].pop();f--,0==h.querySelectorAll("td").length&&(h.toggleTableEditMode(),B.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),h.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(h)}C()},document.getElementsByClassName("wptb-table-generator")[0].style.display="none",array=function(){for(var e=[],t=[],n=0;n<h.rows.length;n++){for(var a=h.rows[n].getElementsByTagName("td"),r=0,l=0;l<a.length;l++)r+=a[l].colSpan;e.push(r)}f=Math.max.apply(null,e);var o=h.rows.length;for(n=0;n<o;n++)for(t[n]=[],l=0;l<f;l++)t[n].push(0);return T(t),t}(),C(),T(array),B.appendChild(h),h.recalculateIndexes(!0),WPTB_LeftPanel()};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Text=function(e,t){var n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("p"),l=void 0,o=!1;if(n.classList.add("wptb-text-container"),r.innerHTML=null!=e?e:"Text",a.appendChild(r),n.appendChild(a),t){var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(l=s[1],o=!0);for(var i=[].concat(_toConsumableArray(t.attributes)),d=0;d<i.length;d++)n.setAttribute(i[d].name,i[d].value)}return this.kind="text",this.getDOMElement=function(){return n},applyGenericItemSettings(this,l,o),this},WPTB_innerElementSet=function m(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,n=void 0;if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.getData("wptbElement")||e.dataTransfer.getData("node")){var a,r=void 0,l=void 0;if(0<document.getElementsByClassName("wptb-drop-handle").length&&(r=document.getElementsByClassName("wptb-drop-handle")[0]),0<document.getElementsByClassName("wptb-drop-border-marker").length&&(l=document.getElementsByClassName("wptb-drop-border-marker")[0]),e.dataTransfer.getData("wptbElement")?t=(t="list"==(a=e.dataTransfer.getData("wptbElement"))?new WPTB_List:"image"==a?new WPTB_Image:"text"==a?new WPTB_Text:"button"==a?new WPTB_Button:void 0).getDOMElement():(n=e.dataTransfer.getData("node"),(t=document.getElementsByClassName(n)[0]).classList.remove("wptb-moving-mode")),"block"==r.style.display){var o=void 0;if("Drop Here"==r.dataset.text)(o=r.getDOMParentElement()).appendChild(t);else{var s=r.getDOMParentElement();if(o=s.parentNode,"Abowe Element"==r.dataset.text)o.insertBefore(t,s);else if("Below Element"==r.dataset.text){var i=s.nextSibling;o.insertBefore(t,i)}}var d=o.parentNode;if(d.classList.contains("wptb-table-head")){var c=WPTB_Helper.findAncestor(d,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(c)}return r.style.display="none",l.style.display="none",m(t),!0}}},t.onmouseover=function(e){t.classList.remove("wptb-ondragenter")}},applyGenericItemSettings=function(p,e){var t,u,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],b=p.getDOMElement();if(null==e||1==n){t=document.counter.nextIndex(p.kind);for(var a=document.getElementsByClassName("wptb-ph-element"),r=[],l=0;l<a.length;l++){var o=new RegExp("wptb-element-"+p.kind+"-(\\d+)","i"),s=a[l].className.match(o);s&&r.push(s[1])}if(0<r.length)t=Math.max.apply(Math,r)+1;else t=1}else e&&!n&&(t=e.split("-")[1]);if(b.onmouseenter=function(e){this.classList.add("wptb-directlyhovered");var t=document.createElement("span"),n=document.createElement("span"),a=document.createElement("span"),r=document.createElement("span");r.classList.add("wptb-actions"),t.classList.add("dashicons","dashicons-trash","wptb-delete-action"),n.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),a.classList.add("dashicons","dashicons-move","wptb-move-action"),a.draggable=!0,t.onclick=function(e){var t=this.parentNode.parentNode,n=t.parentNode;if(n.removeChild(t),"text"==t.kind){var a=n.parentNode;if(a.classList.contains("wptb-table-head")){var r=WPTB_Helper.findAncestor(a,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(r)}}},n.onclick=function(e){var t=void 0;if("list"==p.kind){e.target.parentNode.parentNode.parentNode;for(var n=[],a=e.target.parentNode.parentNode.querySelectorAll("ul li .wptb-list-item-content"),r=0;r<a.length;r++)n.push(a[r].innerHTML);t=new WPTB_List(n,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else if("text"==p.kind){e.target.parentNode.parentNode.parentNode;t=new WPTB_Text(e.target.parentNode.parentNode.childNodes[0].innerHTML,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else if("image"==p.kind){e.target.parentNode.parentNode.parentNode;t=new WPTB_Image(e.target.parentNode.parentNode.children[0].children[0].src,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else{e.target.parentNode.parentNode.parentNode;var l=e.target.parentNode.parentNode.childNodes[0].querySelector("p").innerHTML;t=new WPTB_Button(l,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}WPTB_innerElementSet(t.getDOMElement())};var l,o,s=this;l=s.className.match(/wptb-element-(.+)-(\d+)/i),o=l[1];var i=WPTB_Helper.dragImagesArr();if(a.ondragstart=function(e){if(this.parentNode.style.opacity=0,s.classList.remove("wptb-directlyhovered"),s.classList.add("wptb-moving-mode"),e.dataTransfer.setDragImage(i[o],0,0),e.dataTransfer.setData("node","wptb-element-"+l[1]+"-"+l[2]),e.dataTransfer.setData("wptb-moving-mode","wptb-element-"+l[1]+"-"+l[2]),e.dataTransfer.setData("wptbElIndic-"+l[1],"wptbElIndic-"+l[1]),"text"==e.target.parentNode.parentNode.kind){var t=el.parentNode;if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}}},"button"===p.kind){var d=b.querySelector("a"),c=d.querySelector("div");d.onclick=function(e){e.preventDefault()},WPTB_Helper.buttonsTinyMceInit(c)}else if("text"===p.kind)tinyMCE.init({target:b.childNodes[0],inline:!0,plugins:"link, paste",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",paste_as_text:!0,toolbar:"bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify",setup:function(e){e.on("change",function(e){var t=WPTB_Helper.findAncestor(b,"wptb-row");if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}});else{u=b.getElementsByClassName("wptb-list-item-content");for(var m=0;m<u.length;m++)WPTB_Helper.listItemsTinyMceInit(u[m])}r.appendChild(a),r.appendChild(n),r.appendChild(t),this.appendChild(r)},b.onmouseleave=function(e){this.classList.remove("wptb-directlyhovered");for(var t=0;e.target.querySelector(".wptb-actions")&&t<5;)e.target.querySelector(".wptb-actions").remove(),t++},"text"==p.kind){new MutationObserver(function(e){var t=WPTB_Helper.findAncestor(b,"wptb-row");if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}}).observe(p.getDOMElement(),{attributes:!0,attributeFilter:["style"]})}var i=b.className.match(/wptb-element-(.+)-(\d+)/i);i&&b.classList.remove(i[0]),b.classList.contains("wptb-ph-element")||b.classList.add("wptb-ph-element"),b.classList.contains("wptb-element-"+p.kind+"-"+t)||b.classList.add("wptb-element-"+p.kind+"-"+t),new WPTB_ElementOptions(p,t,e),document.counter.increment(p.kind)};
1
+ function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}document.addEventListener("DOMContentLoaded",function(){var e=WPTB_Helper.detectMode();if(e){var n=new XMLHttpRequest,t=ajaxurl+"?action=get_table&id="+e;n.open("GET",t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(n.responseText);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])),WPTB_Table(),WPTB_LeftPanel(),WPTB_Settings()):document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},n.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_Button=function(e,t){var n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("a"),l=document.createElement("div"),o=void 0,s=!1;if(n.classList.add("wptb-button-container","wptb-size-M","wptb-"),a.classList.add("wptb-button-wrapper"),l.classList.add("wptb-button"),l.innerHTML=null!=e?e:"Button Text",t){var i=t.className.match(/wptb-element-((.+-)\d+)/i);i&&Array.isArray(i)&&(o=i[1],s=!0);var d=[].concat(_toConsumableArray(t.attributes));if(0<d.length)for(var c=0;c<d.length;c++)n.setAttribute(d[c].name,d[c].value);var m=t.querySelector(".wptb-button-wrapper");if(m){var p=[].concat(_toConsumableArray(m.attributes));if(0<p.length)for(var u=0;u<p.length;u++)"style"==p[u].name&&a.setAttribute(p[u].name,p[u].value)}var b=t.querySelector("a");if(b){var g=[].concat(_toConsumableArray(b.attributes));if(0<g.length)for(var y=0;y<g.length;y++)"style"!=g[y].name&&"href"!=g[y].name&&"target"!=g[y].name||r.setAttribute(g[y].name,g[y].value)}}return a.appendChild(r),r.appendChild(l),n.appendChild(a),this.kind="button",this.getDOMElement=function(){return n},applyGenericItemSettings(this,o,s),this},WPTB_Cell=function(e,s){if(!s){(s=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)&&(s.style.border=t+"px solid "+jQuery("#wptb-table-border-color").val()),s.classList.add("wptb-droppable","wptb-cell")}s.draggable=!1,e&&(s.onclick=e),WPTB_innerElementSet(s);var i=s.getElementsByClassName("wptb-ph-element");if(0<i.length)for(var n=function(e){var t=s.getElementsByClassName("wptb-space-between");if(0<t.length)for(var n=0;n<t.length;n++)WPTB_Space(t[n]);i[e].getDOMElement=function(){return i[e]},WPTB_innerElementSet(i[e]);var a=i[e].className.match(/wptb-element-((.+-)\d+)/i);if(a&&Array.isArray(a)){var r=a[1].split("-");if(i[e].kind=r[0],applyGenericItemSettings(i[e],a[1]),"list"==i[e].kind){var l=i[e].getElementsByTagName("li");if(0<l.length)for(var o=0;o<l.length;o++)WPTB_ListItem(void 0,l[o])}}},a=0;a<i.length;a++)n(a);return this.getDOMElement=function(){return s},this.setCoords=function(e,t){var n=this.getDOMElement();n.dataset.yIndex=e,n.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)},this},WPTB_DropHandle=function(i,e){var d=void 0,c=void 0;if(0==document.getElementsByClassName("wptb-drop-handle").length){(d=document.createElement("div")).classList.add("wptb-drop-handle"),(c=document.createElement("div")).classList.add("wptb-drop-border-marker");var t=document.createElement("div"),n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("div");t.classList.add("wptb-drop-border-marker-top"),n.classList.add("wptb-drop-border-marker-right"),a.classList.add("wptb-drop-border-marker-bottom"),r.classList.add("wptb-drop-border-marker-left"),c.appendChild(t),c.appendChild(n),c.appendChild(a),c.appendChild(r);var l=document.getElementsByTagName("body");0<l.length&&(l[0].appendChild(d),l[0].appendChild(c)),d.ondragenter=function(){},d.ondragover=function(e){e.preventDefault()},d.ondragleave=function(){},d.ondrop=function(e){e.preventDefault();var t,n=void 0;e.dataTransfer.getData("wptbElement")?n=(n=(t=e.dataTransfer.getData("wptbElement")).includes("list")?new WPTB_List:t.includes("image")?new WPTB_Image:t.includes("text")?new WPTB_Text:t.includes("button")?new WPTB_Button:void 0).getDOMElement():((n=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).classList.remove("wptb-moving-mode"),n.classList.remove("wptb-moving-into-same-elem"));var a=void 0;if("Drop Here"==d.dataset.text)"td"==(i=d.getDOMParentElement()).nodeName.toLowerCase()&&(a=d.getDOMParentElement()).appendChild(n);else{var r=d.getDOMParentElement();if(a=r.parentNode,"Abowe Element"==d.dataset.text)a.insertBefore(n,r);else if("Below Element"==d.dataset.text){var l=r.nextSibling;a.insertBefore(n,l)}}var o=a.parentNode;if(o.classList.contains("wptb-table-head")){var s=WPTB_Helper.findAncestor(o,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(s)}d.style.display="none",c.style.display="none",WPTB_innerElementSet(n)},document.querySelector(".wptb-container").onscroll=function(){d.style.display="none",c.style.display="none"}}else d=document.getElementsByClassName("wptb-drop-handle")[0],c=document.getElementsByClassName("wptb-drop-border-marker")[0];if(!i||"td"!=i.nodeName.toLowerCase()||0==i.getElementsByClassName("wptb-ph-element").length){var o=void 0;if("td"==i.localName?o=i.parentNode:"div"==i.localName&&i.classList.contains("wptb-ph-element")&&(o=i.parentNode.parentNode),o.classList.contains("wptb-table-head")){for(var s=e.dataTransfer.types,m=!1,p=0;p<s.length;p++){var u=s[p].match(/wptbelindic-([a-z]+)/i);if(u&&"text"!=u[1]){m=!0;break}}if(m)return}d.style.width=i.offsetWidth+"px";var b=i.offsetHeight,g=i.getBoundingClientRect(),y=Number(g.left),f=void 0;if(d.style.left=y+"px",-1!=e.dataTransfer.types.indexOf("wptb-moving-mode")){var v=document.getElementsByClassName("wptb-moving-mode")[0];i==v?(d.classList.add("wptb-moving-into-same-elem"),c.classList.add("wptb-moving-into-same-elem")):(d.classList.remove("wptb-moving-into-same-elem"),c.classList.remove("wptb-moving-into-same-elem"))}if(d.getDOMParentElement=function(){return i},d.style.display="block",c.style.display="block","td"!=i.nodeName.toLowerCase()){var h=null==e.offsetY?e.layerY:e.offsetY;f=Number(g.top)-Number(11),d.dataset.text="Abowe Element",b/2<h&&(f=Number(g.top)+b-1,d.dataset.text="Below Element")}else d.dataset.text="Drop Here",f=Number(g.top)+b/2-5;d.style.top=f+"px",c.style.top=g.top+"px",c.style.left=g.left+"px",wptbDropBorderMarkerTop=c.querySelector(".wptb-drop-border-marker-top"),wptbDropBorderMarkerTop.style.width=Number(i.offsetWidth)-Number(1)+"px",wptbDropBorderMarkerRight=c.querySelector(".wptb-drop-border-marker-right"),wptbDropBorderMarkerRight.style.height=Number(g.bottom)-Number(g.top)-1+"px",wptbDropBorderMarkerRight.style.left=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom=c.querySelector(".wptb-drop-border-marker-bottom"),wptbDropBorderMarkerBottom.style.width=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom.style.top=wptbDropBorderMarkerRight.style.height,wptbDropBorderMarkerLeft=c.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_ElementOptions=function(e,t,n){var a,r=e.getDOMElement();prop=document.querySelector(".wptb-"+e.kind+"-options-prototype").cloneNode(!0),prop.classList.remove("wptb-"+e.kind+"-options-prototype"),a="wptb-options-"+e.kind+"-"+t;for(var l=prop.getElementsByClassName("wptb-element-property"),o=0;o<l.length;o++)l[o].dataset.element=a;if(prop.classList.add(a),document.getElementById("element-options-group").appendChild(prop),n)if("button"==e.kind){var s=document.getElementsByClassName("wptb-element-"+n)[0],i=void 0,d=void 0,c=void 0,m=void 0;if(s&&(m=s.className.match(/wptb-size-([a-z]+)/i)),m&&Array.isArray(m)){var p=prop.getElementsByClassName("wptb-btn-size-btn");for(o=0;o<p.length;o++)p[o].classList.remove("selected"),p[o].innerHTML==m[1]&&p[o].classList.add("selected")}if(s&&(i=s.getElementsByClassName("wptb-button-wrapper"),d=s.getElementsByTagName("a"),c=s.getElementsByClassName("wptb-button")),i){var u=i[0].style.justifyContent,b=prop.querySelector('select[data-type="button-alignment"]').getElementsByTagName("option"),g=void 0;"flex-start"==u?g="left":"center"!=u&&u?"flex-end"==u&&(g="right"):g="center";for(var y=0;y<b.length;y++)b[y].value==g&&(b[y].selected=!0)}if(0<d.length){var f=d[0].getAttribute("href"),v=d[0].getAttribute("target"),h=d[0].getAttribute("id"),w=prop.querySelector('input[data-type="button-link"]'),B=prop.querySelector('input[data-type="button-link-target"]'),E=B.getAttribute("id"),T=B.parentNode.getElementsByTagName("label")[0],C=prop.querySelector('input[data-type="button-id"]');E=E+"-"+n.split("-")[1],B.setAttribute("id",E),T.setAttribute("for",E),w.value=f,v&&"_blank"==v&&(B.checked=!0),C.value=h}if(c){var N=c[0].style.color,S=c[0].style.backgroundColor,x=prop.querySelector('input[data-type="button-text-color"]'),I=prop.querySelector('input[data-type="button-color"]');x.value=WPTB_Helper.rgbToHex(N),I.value=WPTB_Helper.rgbToHex(S)}}else if("image"==e.kind){var k=document.getElementsByClassName("wptb-element-"+n);if(0<k.length){var _=k[0].getElementsByTagName("a");if(0<_.length){var L=_[0];if(L){L.onclick=function(e){e.preventDefault()};for(var A=L.style.textAlign,P=prop.querySelector('select[data-type="image-alignment"]').getElementsByTagName("option"),W=0;W<P.length;W++)P[W].value==A&&(P[W].selected=!0);var M=L.getAttribute("href"),D=prop.querySelector('input[data-type="image-link"]');M&&(D.value=M);var q=L.getAttribute("target"),H=prop.querySelector('input[data-type="image-link-target"]'),O=H.getAttribute("id"),R=H.parentNode.getElementsByTagName("label")[0];O=O+"-"+n.split("-")[1],H.setAttribute("id",O),R.setAttribute("for",O),q&&"_blank"==q&&(H.checked=!0);var z=L.getElementsByTagName("img");if(0<z.length){var j=z[0].style.width;if(j){var Q=prop.querySelector('input[type="range"][data-type="image-size"]'),F=prop.querySelector('input[type="number"][data-type="image-size"]');Q.value=parseInt(j),F.value=parseInt(j)}var G=z[0].getAttribute("alt");prop.querySelector('input[type="text"][data-type="alternative-text"]').value=G}}}}}else if("text"==e.kind){var J=document.getElementsByClassName("wptb-element-"+n);if(0<J.length){var Y=J[0].style.fontSize,X=J[0].style.color,K=prop.querySelector('input[type="range"][data-type="font-size"]'),U=prop.querySelector('input[type="number"][data-type="font-size"]'),$=prop.querySelector('input[type="text"][data-type="color"]');K.value=parseInt(Y),U.value=parseInt(Y),$.value=WPTB_Helper.rgbToHex(X)}}else if("list"==e.kind){var V=document.getElementsByClassName("wptb-element-"+n);if(0<V.length){var Z=V[0].querySelector("p").style.color;prop.querySelector('input[type="text"][data-type="list-text-color"]').value=WPTB_Helper.rgbToHex(Z);var ee=V[0].querySelectorAll("li");if(0<ee.length){var te=ee[0].querySelector("p").classList;if(0<te.length){var ne=prop.querySelector('select[data-type="list-class"]');if(ne){ne.value="unordered";for(var ae=ne.parentNode.nextSibling,re=0;re<10&&"1"!=ae.nodeType;re++)ae=ae.nextSibling;if(ae){var le=ae.getAttribute("id");ae.setAttribute("id",le+"-"+n),ae.style.display="flex"}var oe=prop.querySelector('select[data-type="list-style-type"]');oe&&(oe.parentNode.style.display="flex",te.contains("wptb-list-style-type-disc")?oe.value="disc":te.contains("wptb-list-style-type-circle")?oe.value="circle":te.contains("wptb-list-style-type-square")?oe.value="square":te.contains("wptb-list-style-type-none")&&(oe.value="none"))}}}var se=V[0].getElementsByClassName("wptb-list-item-content");if(0<se.length){for(var ie=[],de=0;de<se.length;de++){var ce=se[de].querySelector("p");ce&&(ce.style.textAlign?ie.push(ce.style.textAlign):ie.push("left"))}var me=0,pe=0,ue=0;if(0<ie.length)for(var be=0;be<ie.length;be++)ie[be]&&("left"==ie[be]?me++:"center"==ie[be]?pe++:"right"==ie[be]&&ue++);var ge=prop.querySelector('select[data-type="list-alignment"]'),ye=Math.max(me,pe,ue);me==ye?ge.value="left":pe==ye?ge.value="center":ue==ye&&(ge.value="right")}}}if(r.onclick=function(){var e=this.className.match(/wptb-element-((.+-)\d+)/i),t=".wptb-"+e[2]+"options.wptb-options-"+e[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";for(var n=document.getElementById("element-options-group").childNodes,a=0;a<n.length;a++)n[a].style&&(n[a].style.display="none");document.querySelector(t).style.display="block"},"button"==e.kind){var fe=prop.getElementsByClassName("wptb-btn-size-btn");for(o=0;o<fe.length;o++)fe[o].onclick=function(){var e=this.innerHTML,t=this.dataset.element.match(/wptb-options-(.+)-(\d+)/i),n=t[1],a=t[2],r=document.getElementsByClassName("wptb-element-"+n+"-"+a)[0];r.classList.remove("wptb-size-S"),r.classList.remove("wptb-size-M"),r.classList.remove("wptb-size-L"),r.classList.remove("wptb-size-XL"),r.classList.add("wptb-size-"+e);for(var l=this.parentNode.getElementsByClassName("wptb-btn-size-btn"),o=0;o<l.length;o++)l[o].classList.remove("selected");this.classList.add("selected")}}var ve=prop.getElementsByClassName("wptb-element-property");for(o=0;o<ve.length;o++){if(ve[o].classList.contains("wptb-color-picker")&&jQuery(ve[o]).wpColorPicker({change:function(e,t){var n,a,r,l=e.target;if(a=(n=l.dataset.element.match(/wptb-options-(.+)-(\d+)/i))[1],r=n[2],affectedEl=document.getElementsByClassName("wptb-element-"+a+"-"+r)[0],"button"==a)"button-text-color"==l.dataset.type?affectedEl.getElementsByClassName("wptb-button")[0].style.color=t.color.toString():affectedEl.getElementsByClassName("wptb-button")[0].style.backgroundColor=t.color.toString();else if("list"==a){var o=affectedEl.querySelectorAll("p");if(0<o.length)for(var s=0;s<o.length;s++)o[s].style.color=t.color.toString()}else affectedEl.style.color=t.color.toString()}}),"font-size"===ve[o].dataset.type)ve[o].parentNode.parentNode.getElementsByClassName("wptb-text-font-size-slider")[0].oninput=function(){this.parentNode.parentNode.getElementsByClassName("wptb-text-font-size-number")[0].value=this.value,this.parentNode.parentNode.getElementsByClassName("wptb-text-font-size-number")[0].onchange()};if("image-size"===ve[o].dataset.type)ve[o].parentNode.parentNode.getElementsByClassName("wptb-image-size-slider")[0].oninput=function(){this.parentNode.parentNode.getElementsByClassName("wptb-image-width-number")[0].value=this.value,this.parentNode.parentNode.getElementsByClassName("wptb-image-width-number")[0].onchange()};ve[o].onchange=function(e){var t=this.dataset.element.match(/wptb-options-(.+)-(\d+)/i),n=t[1],a=t[2],r=document.getElementsByClassName("wptb-element-"+n+"-"+a)[0],l=this.value;switch(this.dataset.type){case"src":r.getElementsByTagName("img")[0].src=this.value;break;case"alternative-text":r.getElementsByTagName("img")[0].alt=this.value;break;case"image-link":r.getElementsByTagName("a")[0].href=WPTB_Helper.linkHttpCheckChange(this.value);break;case"image-link-target":1==this.checked?r.getElementsByTagName("a")[0].target="_blank":r.getElementsByTagName("a")[0].target="_self";break;case"image-link-nofollow":1==this.checked?r.getElementsByTagName("a")[0].rel="nofollow":r.getElementsByTagName("a")[0].removeAttribute("rel");break;case"image-size":r.getElementsByTagName("img")[0].style.width=this.value+"%",r.getElementsByTagName("img")[0].style.height="auto",this.parentNode.parentNode.getElementsByClassName("wptb-image-size-slider")[0].value=this.value;break;case"image-alignment":r.getElementsByTagName("img")[0].parentNode.style.textAlign=this.value;break;case"font-size":r.style.fontSize=l+"px";break;case"button-alignment":var o="";o="left"==this.value?"start":"right"==this.value?"flex-end":"center",r.getElementsByClassName("wptb-button-wrapper")[0].style.justifyContent=o;break;case"button-link":this.value?r.getElementsByTagName("a")[0].href=WPTB_Helper.linkHttpCheckChange(this.value):r.getElementsByTagName("a")[0].removeAttribute("href");break;case"button-link-target":1==this.checked?r.getElementsByTagName("a")[0].target="_blank":r.getElementsByTagName("a")[0].target="_self";break;case"button-link-nofollow":1==this.checked?r.getElementsByTagName("a")[0].rel="nofollow":r.getElementsByTagName("a")[0].removeAttribute("rel");break;case"button-id":this.value?r.getElementsByTagName("a")[0].id=this.value:r.getElementsByTagName("a")[0].removeAttribute("id");case"button-color":break;case"list-alignment":for(var s=r.querySelectorAll("li"),i=0;i<s.length;i++){var d=s[i].querySelector("p");d&&(d.style.textAlign=this.value)}break;case"list-class":var c=e.target.parentNode.parentNode.querySelector("[data-type=list-style-type]").parentNode,m=c.parentNode;if("unordered"==l){c.style.display="flex",m.querySelector(".wptb-list-icon-select-label").style.display="flex";var p=r.querySelectorAll("li");for(i=0;i<p.length;i++){var u=p[i].querySelector("p");u.removeAttribute("class"),u.classList.add("wptb-list-style-type-disc")}m.querySelector("[data-type=list-style-type]").value="disc"}else{c.style.display="none",m.querySelector(".wptb-list-icon-select-label").style.display="none";var b=r.querySelectorAll("li");for(i=0;i<b.length;i++){b[i].querySelector("p").removeAttribute("class")}}break;case"list-style-type":for(b=r.querySelectorAll("li"),i=0;i<b.length;i++){var g=b[i].querySelector("p");g.removeAttribute("class"),g.classList.add("list-style-type-"+l.toLowerCase())}}}}},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):""},getDragImageCustom:function(e){var t=location.protocol+"//"+location.hostname,n=document.createElement("img");return n.src=t+"/wp-content/plugins/wp-table-builder/inc/admin/views/builder/icons/"+e+".png",n},dragImagesArr:function(){return{text:WPTB_Helper.getDragImageCustom("text"),image:WPTB_Helper.getDragImageCustom("image"),button:WPTB_Helper.getDragImageCustom("button"),list:WPTB_Helper.getDragImageCustom("list")}},listItemsRecalculateIndex:function(e){var t=e.querySelectorAll("p");if(0<t.length)for(var n=0;n<t.length;n++)t[n].dataset.listStyleTypeIndex=Number(n)+1+"."},listItemsTinyMceInit:function(e){tinyMCE.init({target:e,inline:!0,plugins:"link, paste",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",paste_as_text:!0,toolbar:"bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify",setup:function(e){e.on("keydown",function(e){var t=e.target.parentNode;if(13==e.keyCode){e.preventDefault();var n=e.target.innerHTML,a=new WPTB_ListItem(n,t,!0);t.parentNode.insertBefore(a.getDOMElement(),t),WPTB_Helper.listItemsTinyMceInit(a.getDOMElement().firstChild),e.target.querySelector("p").innerText="New List Item",WPTB_Helper.listItemsRecalculateIndex(t.parentNode)}else if("8"==e.keyCode||"46"==e.keyCode){var r=e.target.querySelector("p").innerHTML.replace(/<[^>]+>/g,"");if(""==(r=(r=r.replace(/\s+/g," ").trim()).replace(/&nbsp;/g,"").trim()))e.preventDefault(),e.target.querySelector("p").innerText="\n";else{var l=WPTB_Helper.getSelectionText();(l=(l=l.replace(/\s+/g," ").trim()).replace(/&nbsp;/g,"").trim())==r&&(e.preventDefault(),e.target.querySelector("p").innerText="\n")}}}),e.on("keyup",function(e){})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}})},buttonsTinyMceInit:function(e){tinyMCE.init({target:e,inline:!0,plugins:"link",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",toolbar:"bold italic strikethrough",setup:function(e){e.on("keydown",function(e){13==e.keyCode&&e.preventDefault()})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}})},linkHttpCheckChange:function(e){if(e){if(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))return e;var t=e.split("/"),n=void 0;return Array.isArray(t)&&0<t.length&&(n=t[t.length-1]),document.location.protocol+"//"+n}return""},dataTitleColumnSet:function(e){for(var t=e.rows,n=t[0],a=getComputedStyle(n),r=n.children,l={},o=0;o<r.length;o++){for(var s=r[o].children,i=0;i<s.length;i++){var d=s[i];if(d.classList.contains("wptb-ph-element")){d.getAttribute("style");if("text"==d.className.match(/wptb-element-(.+)-(\d+)/i)[1]){var c=d.querySelector("p"),m=c.textContent,p=c.style.textAlign;l[r[o].dataset.xIndex]=[m,d.style.fontSize,d.style.color,a.backgroundColor,p];break}}}l[r[o].dataset.xIndex]||(l[r[o].dataset.xIndex]=["","","",a.backgroundColor,""])}for(var u=1;u<t.length;u++)for(var b=t[u].children,g=0;g<b.length;g++)l[b[g].dataset.xIndex]?(b[g].dataset.titleColumn=l[b[g].dataset.xIndex][0],b[g].dataset.titleColumnFontSize=l[b[g].dataset.xIndex][1],b[g].dataset.titleColumnColor=l[b[g].dataset.xIndex][2],b[g].dataset.titleBackgroundColor=l[b[g].dataset.xIndex][3],b[g].dataset.titleAlign=l[b[g].dataset.xIndex][4]):(b[g].dataset.titleColumn="",b[g].dataset.titleColumnFontSize="",b[g].dataset.titleColumnColor="",b[g].dataset.titleBackgroundColor="",b[g].dataset.titleAlign="")},findAncestor:function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e},getSelectionText:function(){return window.getSelection?window.getSelection().toString():document.selection.createRange().text},settingsPanelClear:function(){document.getElementById("wptb-top-row-as-header").checked=!1,document.getElementById("wptb-table-border-slider").value=0,document.getElementById("wptb-table-border-number").value=0,document.getElementById("wptb-inner-border-check").checked=!1,document.getElementById("wptb-apply-inner-border").classList.remove("visible"),document.getElementById("wptb-table-inner-border-slider").value=1,document.getElementById("wptb-table-inner-border-number").value=1,WPTB_Helper.wpColorPickerClear("wptb-table-border-color"),WPTB_Helper.wpColorPickerClear("wptb-table-header-bg"),WPTB_Helper.wpColorPickerClear("wptb-even-row-bg"),WPTB_Helper.wpColorPickerClear("wptb-odd-row-bg"),document.getElementById("wptb-table-cell-slider").value=15,document.getElementById("wptb-table-cell-number").value=15},wpColorPickerClear:function(e){var t=document.getElementById(e),n=WPTB_Helper.findAncestor(t,"wp-picker-container"),a=n.parentNode;a.removeChild(n);var r=document.createElement("input");r.setAttribute("id",e),r.value="",a.appendChild(r)},detectMode:function(){var e=window.location.href,t=new RegExp("[?&]table(=([^&#]*)|&|#|$)").exec(e);return!!t&&(t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"")}},WPTB_Image=function(e,t){var n=void 0,a=void 0,r=!1;if(null==t){n=document.createElement("div");var l=document.createElement("a"),o=document.createElement("img");l.style.display="inline-block",l.appendChild(o),n.appendChild(l),l.onclick=function(e){e.preventDefault()},file_frame=wp.media.frames.file_frame=wp.media({title:"Select a image to upload",button:{text:"Use this image"},multiple:!1}),file_frame.on("select",function(){attachment=file_frame.state().get("selection").first().toJSON(),o.src=attachment.url}),null==e?file_frame.open():o.src=e}else{(n=t.cloneNode(!0)).getElementsByTagName("a")[0].onclick=function(e){e.preventDefault()};var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(a=s[1],r=!0)}return this.kind="image",this.getDOMElement=function(){return n},applyGenericItemSettings(this,a,r),this},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<10&&columnsInput.value++},rowsDecrementButton.onclick=function(){1<rowsInput.value&&rowsInput.value--},rowsIncrementButton.onclick=function(){rowsInput.value<10&&rowsInput.value++},document.getElementById("wptb-generate-table").onclick=function(){var e=document.getElementById("wptb-columns-number").value,t=document.getElementById("wptb-rows-number").value;WPTB_Table(e,t)}},WPTB_LeftPanel=function(){var e,t,l=document.getElementsByClassName("wptb-preview-table")[0],n=document.getElementsByClassName("wptb-element");function a(e,t){if(!(3<t)&&l){var n=l.getElementsByTagName("tr");if(n.length>t){var a=n[t].style.backgroundColor,r=document.getElementById(e);r&&a&&(r.value=WPTB_Helper.rgbToHex(a))}}}function r(e){for(var t=l.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.borderWidth=document.querySelector("#wptb-table-inner-border-number").value+"px",t[n].style.borderStyle="solid"}function o(e){for(var t=l.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.padding=e+"px"}function s(e){l.style.borderWidth=e+"px",l.style.borderStyle="solid"}function i(e,t,n){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;e=String(e),n<e&&(this.value=n)}}a("wptb-even-row-bg",1),jQuery("#wptb-even-row-bg").wpColorPicker({change:function(e,t){for(var n=l.getElementsByTagName("tr"),a=1;a<n.length;a+=2)n[a].style.backgroundColor=t.color.toString()},clear:function(){for(var e=l.getElementsByTagName("tr"),t=1;t<e.length;t+=2){e[t].style.backgroundColor="";for(var n=e[t].getElementsByTagName("td"),a=0;a<n.length;a++)n[a].style.backgroundColor=""}}}),a("wptb-odd-row-bg",2),jQuery("#wptb-odd-row-bg").wpColorPicker({change:function(e,t){for(var n=l.getElementsByTagName("tr"),a=2;a<n.length;a+=2)n[a].style.backgroundColor=t.color.toString()},clear:function(){for(var e=l.getElementsByTagName("tr"),t=2;t<e.length;t+=2){e[t].style.backgroundColor="";for(var n=e[t].getElementsByTagName("td"),a=0;a<n.length;a++)n[a].style.backgroundColor=""}}}),a("wptb-table-header-bg",0),jQuery("#wptb-table-header-bg").wpColorPicker({change:function(e,t){l.getElementsByTagName("tr")[0].style.backgroundColor=t.color.toString()},clear:function(){var e=l.getElementsByTagName("tr")[0];e.style.backgroundColor="";for(var t=e.getElementsByTagName("td"),n=0;n<t.length;n++)t[n].style.backgroundColor=""}}),e=l,t=document.getElementById("wptb-top-row-as-header"),e&&e.classList.contains("wptb-table-preview-head")?t.checked=!0:t.checked=!1,function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].style.borderColor;if(t){var n=document.getElementById("wptb-table-border-color");n&&(n.value=WPTB_Helper.rgbToHex(t))}var a=e[0].style.borderWidth;if(a){var r=document.getElementById("wptb-table-border-slider"),l=document.getElementById("wptb-table-border-number");r&&(r.value=parseInt(a)),l&&(l.value=parseInt(a))}var o=e[0].querySelector("td").style.borderWidth;if(o){var s=document.getElementById("wptb-inner-border-check"),i=document.getElementById("wptb-apply-inner-border");if(o&&0<parseInt(o)){if(s&&(s.checked=!0,i)){i.classList.add("visible");var d=document.getElementById("wptb-table-inner-border-slider"),c=document.getElementById("wptb-table-inner-border-number");d.value=parseInt(o),c.value=parseInt(o)}}else s.checked=!1}(a&&0<parseInt(a)||o&&0<parseInt(o))&&(document.getElementById("wptb-table-border-color-set-area").style.display="")}}(),jQuery("#wptb-table-border-color").wpColorPicker({change:function(e,t){var n=l.getElementsByTagName("td");l.style.border=document.querySelector("#wptb-table-border-number").value+"px solid "+t.color.toString();for(var a=0;a<n.length;a++){var r=document.querySelector("#wptb-table-inner-border-number").value;document.getElementById("wptb-inner-border-check").checked&&(n[a].style.border=(0!=r?r:1)+"px solid "+t.color.toString())}},clear:function(){var e=l.getElementsByTagName("td");l.style.borderColor="";for(var t=0;t<e.length;t++)e[t].style.borderColor=""}}),function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].querySelector("td");if(t){var n=t.style.padding;if(n){var a=document.getElementById("wptb-table-cell-slider"),r=document.getElementById("wptb-table-cell-number");a&&(a.value=parseInt(n)),r&&(r.value=parseInt(n))}}}}(),i(document.getElementById("wptb-table-border-number"),1,50),i(document.getElementById("wptb-table-inner-border-number"),1,50),i(document.getElementById("wptb-table-cell-number"),1,50),i(document.getElementById("wptb-text-font-size-number"),1,50),i(document.getElementById("wptb-image-width-number"),2,100),document.getElementById("wptb-table-cell-slider").oninput=function(){document.getElementById("wptb-table-cell-number").value=this.value,o(this.value)},document.getElementById("wptb-table-cell-number").onchange=function(){document.getElementById("wptb-table-cell-slider").value=this.value,o(this.value)},document.getElementById("wptb-table-border-slider").oninput=function(){document.getElementById("wptb-table-border-number").value=this.value,s(this.value);var e=document.getElementById("wptb-inner-border-check").checked,t=document.getElementById("wptb-table-border-color-set-area");0==this.value&&0==e?t.style.display="none":t.style.display=""},document.getElementById("wptb-table-border-number").onchange=function(){document.getElementById("wptb-table-border-slider").value=this.value,s(this.value)},document.getElementById("wptb-table-inner-border-slider").oninput=function(){document.getElementById("wptb-table-inner-border-number").value=this.value,r(this.value)},document.getElementById("wptb-table-inner-border-number").onchange=function(){document.getElementById("wptb-table-inner-border-slider").value=this.value,r(this.value)},document.getElementById("wptb-inner-border-check").onchange=function(){if(l){var e=this.checked?"checked":"unchecked";!function(e){var t=null!=document.querySelector("#wptb-table-border-color").value?document.querySelector("#wptb-table-border-color").value:"rgb(0,0,0)";0!=document.querySelector("#wptb-table-inner-border-slider").value&&0!=document.querySelector("#wptb-table-inner-border-number").value||(document.querySelector("#wptb-table-inner-border-slider").value=1,document.querySelector("#wptb-table-inner-border-number").value=1);var n=document.querySelector("#wptb-table-inner-border-slider").value+"px",a=document.getElementsByClassName("wptb-preview-table");if(0<a.length)if("checked"==e){document.getElementById("wptb-apply-inner-border").style.marginBottom="0px";for(var r=a[0].getElementsByTagName("td"),l=0;l<r.length;l++)r[l].style.border=n+" solid "+t;document.getElementById("wptb-apply-inner-border").classList.add("visible")}else for(document.getElementById("wptb-apply-inner-border").classList.remove("visible"),r=a[0].getElementsByTagName("td"),l=0;l<r.length;l++)r[l].style.border="0px solid "+t}(e);var t=document.getElementById("wptb-table-border-slider").value,n=document.getElementById("wptb-table-border-color-set-area");n.style.display="unchecked"==e&&0==t?"none":""}},document.getElementById("wptb-top-row-as-header").onchange=function(){!function(e,t){if(t.checked)WPTB_Helper.dataTitleColumnSet(e),e.classList.add("wptb-table-preview-head"),e.rows[0].classList.add("wptb-table-head");else{var n=e.rows;e.classList.remove("wptb-table-preview-head"),n[0].classList.remove("wptb-table-head");for(var a=1;a<n.length;a++)for(var r=n[a].children,l=0;l<r.length;l++)r[l].removeAttribute("data-title-column")}}(l,this)};for(var d=0;d<n.length;d++)n[d].ondragstart=function(e){e.dataTransfer.setData("wptbElement",this.dataset.wptbElement)};l&&(document.getElementById("wptb-activate-cell-management-mode").onclick=l.toggleTableEditMode,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].addEventListener("click",function(e){if(!(e.target.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.target,"wptb-ph-element")||e.target.classList.contains("wptb-fixed-toolbar")||WPTB_Helper.findAncestor(e.target,"wptb-fixed-toolbar"))){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 t=document.getElementById("wpcd_fixed_toolbar");t.hasAttribute("data-toolbar-active-id")&&document.getElementById(t.getAttribute("data-toolbar-active-id")).classList.remove("toolbar-active")}},!1)},WPTB_List=function(e,t){var n,a=document.createElement("ul"),r=document.createElement("div"),l=void 0,o=!1;if(r.classList.add("wptb-list-item-container"),this.kind="list",""===e);else if(e){var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(l=s[1],o=!0);for(d=0;d<e.length;d++){var i=t.querySelector("li");n=new WPTB_ListItem(e[d],i,!0),a.appendChild(n.getDOMElement())}}else for(var d=0;d<3;d++)n=new WPTB_ListItem("<p>List Item "+(d+1)+"</p>"),a.appendChild(n.getDOMElement());return r.appendChild(a),this.getDOMElement=function(){return r},applyGenericItemSettings(this,l,o),WPTB_Helper.listItemsRecalculateIndex(a),this},WPTB_ListItem=function r(e,t,n){var a=void 0;if(null==t||t&&n){null==e&&(e="New List Item");var l=document.createElement("li");if((s=document.createElement("div")).classList.add("wptb-list-item-content"),t){var o=t.getAttribute("style");o&&l.setAttribute("style",o)}l.appendChild(s),s.innerHTML=e,s.onkeyup=window.listItemKeyListener,a=!0}else{var s;(s=(l=t).getElementsByClassName("wptb-list-item-content")[0]).onkeyup=window.listItemKeyListener,a=!1}if(l.onmouseenter=function(e){var t=document.createElement("span"),n=document.createElement("span"),a=document.createElement("span");a.classList.add("wptb-actions"),t.classList.add("dashicons","dashicons-trash","wptb-delete-action"),n.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),this.classList.add("wptb-directlyhovered"),t.onclick=function(){var e=this.parentNode,t=this.parentNode.parentNode,n=t.parentNode;t.removeChild(e),n.removeChild(t),WPTB_Helper.listItemsRecalculateIndex(n)},n.onclick=function(e){var t=e.target.parentNode.parentNode,n=t.querySelector(".wptb-list-item-content").innerHTML,a=new r(n,t,!0);t.parentNode.insertBefore(a.getDOMElement(),l),WPTB_Helper.listItemsTinyMceInit(a.getDOMElement().firstChild),setTimeout(function(){s.innerHTML=n,WPTB_Helper.listItemsRecalculateIndex(t.parentNode)},5)},a.append(n,t),this.appendChild(a)},l.onmouseleave=function(e){this.removeAttribute("class");for(var t=0;e.target.querySelector(".wptb-actions")&&t<5;)e.target.querySelector(".wptb-actions").remove(),t++},this.getDOMElement=function(){return l},a)return this},MultipleSelect=function(){var r=[],n=!1;return this.activateMultipleSelectMode=function(){r=[];for(var e=document.getElementsByClassName("wptb-preview-table")[0].getElementsByTagName("td"),t=0;t<e.length;t++)e[t].classList.remove("wptb-highlighted");n=!0},this.deactivateMultipleSelectMode=function(){n=!1},this.isActivated=function(){return n},this.pushSelectedCell=function(e){n&&(r.push(e),e.classList.add("wptb-highlighted"))},this.selectedCells=function(){return r},this.flushSelectedCells=function(){r=[]},this.getFirst=function(){for(var e,t=1e3,n=1e3,a=r.length-1;0<=a;a--)t>=r[a].dataset.xIndex&&n>=r[a].dataset.yIndex&&(e=r[a],t=r[a].dataset.xIndex,n=r[a].dataset.yIndex);return e},this.getLast=function(){for(var e,t=-1,n=-1,a=r.length-1;0<=a;a--)t<=r[a].dataset.xIndex&&n<=r[a].dataset.yIndex&&(e=r[a],t=r[a].dataset.xIndex,n=r[a].dataset.yIndex);return e},this.removeAllButFirst=function(){for(var e=this.getFirst(),t=1;t<r.length;t++)r[t].classList.add("wptb-fused-cell-"+e.dataset.xIndex+"-"+e.dataset.yIndex)},this};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Parser=function(e){var t=document.createElement("div");t.innerHTML=e;for(var n=t.children[0],a=[].concat(_toConsumableArray(n.querySelectorAll(".wptb-column-title-mobile-container"))),r=0;r<a.length;r++){a[r].parentNode.removeChild(a[r])}for(var l=n.querySelectorAll("td"),o=0;o<l.length;o++)l[o].classList.add("wptb-droppable"),l[o].classList.remove("wptb-column-title-mobile-not-elements");return n},WPTB_Parser2=function(e){if(Array.isArray(e)){var t=void 0;if(1==e.length)return t.appendChild(document.createTextNode(e[0]));if(0 in e){var n=e[0];if(t=document.createElement(n),1 in e&&Array.isArray(e[1]))for(var a=e[1],r=0;r<a.length;r++)Array.isArray(a[r])&&t.setAttribute(a[r][0],a[r][1]);if(2 in e)if(Array.isArray(e[2]))for(var l=0;l<e[2].length;l++)"string"!=typeof e[2][l]||"p"!=n.toLowerCase()?WPTB_Parser(e[2][l])&&t.appendChild(WPTB_Parser(e[2][l])):t.appendChild(document.createTextNode(e[2][l]));else"string"==typeof e[2]&&t.appendChild(document.createTextNode(e[2]))}return t}return!1},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(){var e=document.querySelector(".wptb-drop-handle"),t=document.querySelector(".wptb-drop-border-marker");(e||t)&&(e.style.display="none",t.style.display="none")};var n=document.getElementsByClassName("wptb-shortcode-popup-window-modal")[0];document.getElementsByClassName("wptb-embed-btn")[0].onclick=function(){this.classList.contains("wptb-embed-disable")||n.classList.add("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-shortcode-popup-dark-area")[0].onclick=function(){n.classList.remove("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-shortcode-popup-window-close-icon")[0].onclick=function(){n.classList.remove("wptb-shortcode-popup-show")},document.getElementsByClassName("wptb-save-btn")[0].onclick=function(){var e=document.querySelector(".wptb-edit-bar");e&&e.classList.contains("visible")&&document.getElementsByClassName("wptb-preview-table")[0].toggleTableEditMode();var n=new XMLHttpRequest,t=ajaxurl+"?action=save_table",a=document.getElementById("wptb-setup-name").value.trim(),r=void 0,l=document.getElementsByClassName("wptb-preview-table");if(l=0<l.length?(l=WPTB_Stringifier(l[0])).outerHTML:"",""===a||""===l){var o="";return""===a&&(o+="You must assign a name to the table before saving it.</br>"),""===l&&(o+="Table wasn't created"),(r=document.getElementById("wptb-messaging-area")).innerHTML='<div class="wptb-error wptb-message">Error: '+o+"</div>",r.classList.add("wptb-warning"),void setTimeout(function(){r.removeChild(r.firstChild)},4e3)}var s={title:a,content:l};((rs=WPTB_Helper.detectMode())||(rs=document.wptbId))&&(s.id=rs),s=JSON.stringify(s),n.open("POST",t,!0),n.setRequestHeader("Content-type","application/json; charset=utf-8"),n.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(n.responseText);r=document.getElementById("wptb-messaging-area"),"saved"==t[0]?(document.wptbId=t[1],r.innerHTML='<div class="wptb-success wptb-message">Table "'+a+'" was successfully saved.</div>',document.getElementsByClassName("wptb-embed-btn")[0].classList.remove("wptb-embed-disable"),document.getElementById("wptb-embed-shortcode").value="[wptb id="+t[1]+"]"):r.innerHTML='<div class="wptb-success wptb-message">Table "'+a+'" was successfully updated.</div>',r.classList.add("wptb-success"),setTimeout(function(){r.removeChild(r.firstChild)},4e3)}},n.send(s)}},WPTB_Space=function s(e){var t=void 0;if(e?t=e:(t=document.createElement("div")).classList.add("wptb-space-between"),t.ondragenter=function(){this.classList.add("visible")},t.ondragover=function(e){e.preventDefault()},t.ondragleave=function(){this.classList.remove("visible")},t.ondrop=function(e){e.stopPropagation();for(var t,n,a,r,l=e.target.nextSibling,o=e.target;!o.classList.contains("wptb-droppable");)o=o.parentNode;e.dataTransfer.getData("wptbElement")?(t=(r=e.dataTransfer.getData("wptbElement")).includes("list")?new WPTB_List:r.includes("image")?new WPTB_Image:r.includes("text")?new WPTB_Text:r.includes("button")?new WPTB_Button:void 0,this.classList.remove("visible"),null==l?(o.appendChild(t.getDOMElement()),o.appendChild(new s)):(o.insertBefore(t.getDOMElement(),l),o.insertBefore(new s,l))):(alert(e.dataTransfer.getData("node")),n=(t=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).nextSibling,a=t.parentNode,null!=n&&a.removeChild(n),null==l?(o.appendChild(t),o.appendChild(new s)):(o.insertBefore(t,l),o.insertBefore(new s,l))),this.classList.remove("visible")},!e)return t},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.dataset.reconstraction=1;var n=t.getElementsByTagName("td");if(0<n.length)for(var a=0;a<n.length;a++){for(var r=0;r<n.length;r++)if(1==t.dataset.reconstraction&&1<n[r].colSpan||1<n[r].rowSpan){t.dataset.reconstraction=0;break}e.querySelector("wptb-table-preview-head")&&n[a].removeAttribute("data-x-index"),n[a].removeAttribute("data-y-index"),n[a].removeAttribute("draggable"),n[a].classList.remove("wptb-droppable");var l=n[a].getElementsByClassName("wptb-ph-element");if(0<l.length)for(var o=0;o<l.length;o++){l[o].classList.remove("wptb-directlyhovered");var s=l[o].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=l[o].querySelectorAll("[data-mce-style]");if(0<d.length)for(var c=0;c<d.length;c++)d[c].removeAttribute("data-mce-style");var m=l[o].querySelectorAll("[contenteditable]");if(0<m.length)for(var p=0;p<m.length;p++)m[p].removeAttribute("contenteditable");var u=l[o].querySelectorAll("[spellcheck]");if(0<u.length)for(var b=0;b<u.length;b++)u[b].removeAttribute("spellcheck");var g=l[o].querySelectorAll("[id^=mce_]");if(0<g.length)for(var y=0;y<g.length;y++)g[y].removeAttribute("id");for(var f=l[o].querySelectorAll(".wptb-actions"),v=f.length;0<v;)f[0].parentNode.removeChild(f[0]),v--}if(n[a].hasAttribute("data-title-column")){var h=document.createElement("div"),w=document.createElement("div");h.classList.add("wptb-column-title-mobile-container"),w.classList.add("column-title-mobile"),w.dataset.titleColumn=n[a].dataset.titleColumn,w.setAttribute("style","font-size:"+n[a].dataset.titleColumnFontSize+"; \n color:"+n[a].dataset.titleColumnColor+"; background-color:"+n[a].dataset.titleBackgroundColor+"; text-align:"+n[a].dataset.titleAlign+";"),w.style.padding=n[a].style.padding,0==n[a].children.length&&n[a].classList.add("wptb-column-title-mobile-not-elements"),h.appendChild(w),n[a].insertBefore(h,n[a].firstChild)}}return t}};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Stringifier2=function(e){1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(null==e)return"";if(null==e.tagName&&3==e.nodeType)return e.nodeValue;var t=[],n=void 0,a=!1,r=[].concat(_toConsumableArray(e.attributes)),l=[],o=[];if((e.parentNode.classList.contains("wptb-list-item-content")||e.parentNode.classList.contains("mce-content-body"))&&"p"==e.tagName.toLowerCase()?(n=e.childNodes,a=!0):n=0<e.children.length?e.children:e.childNodes,0<r.length)for(var s=0;s<r.length;s++)l[s]=[r[s].name,r[s].value];else l="";if(0<n.length)for(var i=0;i<n.length;i++){var d=WPTB_Stringifier(n[i]);Array.isArray(d)||a?o[i]=d:"string"==typeof d&&d&&(o=d)}else o="";return t.push(e.tagName.toLowerCase(),l,o),t},_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},array=[],WPTB_Table=function(e,t){var w,n,a,f,r=document.getElementsByClassName("wptb-settings-items"),B=document.getElementsByClassName("wptb-table-setup")[0],E=function(e){var t,n=this.rowSpan,a=this.colSpan,r=document.getElementsByClassName("wptb-no-cell-action"),l=document.getElementsByClassName("wptb-single-action"),o=document.getElementsByClassName("wptb-multiple-select-action"),s=N(this),i=s[0],d=s[1];if(document.select.isActivated()){if(this.className.match(/wptb-highlighted/)){this.classList.remove("wptb-highlighted");for(var c=0;c<n;c++)for(var m=0;m<a;m++)array[i+c][d+m]=0}else{this.classList.add("wptb-highlighted");for(c=0;c<n;c++)for(m=0;m<a;m++)array[i+c][d+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<r.length;c++)r[c].classList.add("visible"),r[c].removeAttribute("disabled");for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled")}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<r.length;c++)r[c].classList.remove("visible"),r[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.add("visible"),l[c].removeAttribute("disabled")}else{for(c=0;c<o.length;c++)w.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<r.length;c++)r[c].classList.remove("visible"),r[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled")}}},T=function(e){for(var t=0;t<e.length;t++){for(var n=0;n<e[t].length;n++)" "+e[t][n];"\n"}w.isSquare(e)},C=function(){for(var e=document.getElementsByClassName("wptb-no-cell-action"),t=document.getElementsByClassName("wptb-single-action"),n=document.getElementsByClassName("wptb-multiple-select-action"),a=w.getElementsByClassName("wptb-highlighted");a.length;)a[0].classList.remove("wptb-highlighted");for(var r=0;r<array.length;r++)for(var l=0;l<array[r].length;l++)array[r][l]=0;for(r=0;r<n.length;r++)n[r].classList.remove("visible"),n[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")},N=function(e){for(var t=[],n=0;n<f;n++)t[n]=0;for(n=0;n<w.rows.length;n++)for(var a=w.rows[n].getElementsByTagName("td"),r=cellPointer=0;r<f;r+=stepsToMove)if(stepsToMove=1,t[r])t[r]--;else{var l=a[cellPointer++];if(l==e)return[n,r];if(1<l.rowSpan){for(var o=0;o<l.colSpan;o++)t[r+o]=l.rowSpan-1;stepsToMove=l.colSpan}else 1<l.colSpan&&(stepsToMove=l.colSpan)}};if(jQuery("#wptb-table-header-bg").val(""),jQuery("#wptb-even-row-bg").val(""),jQuery("#wptb-odd-row-bg").val(""),jQuery("#wptb-table-border-color").val(""),jQuery("#wptb-table-inner-border-number,#wptb-table-inner-border-slider").val("0"),jQuery("#wptb-table-border-number,#wptb-table-border-slider").val("0"),jQuery("#wptb-table-padding-number,#wptb-table-padding-slider").val("15"),e||t){for(var l=0;l<r.length;l++)"wptb-apply-inner-border"!==r[l].id&&r[l].classList.add("visible");(w=document.createElement("table")).classList.add("wptb-preview-table");for(l=0;l<t;l++){(n=w.insertRow(-1)).classList.add("wptb-row");for(var g=0;g<e;g++)(a=new WPTB_Cell(E)).setCoords(l,g),n.appendChild(a.getDOMElement())}}else{var o=document.getElementsByClassName("wptb-preview-table");if(0<o.length){var s=(w=o[0]).getElementsByTagName("td");if(0<s.length)for(var i=0;i<s.length;i++)WPTB_Cell(E,s[i])}}w.toggleTableEditMode=function(){var e=document.getElementsByClassName("wptb-edit-bar"),t=document.getElementById("cell_mode_background"),n=document.getElementById("wptb-left-scroll-panel-curtain"),a=document.getElementsByClassName("wptb-preview-table");if(0<a.length&&(a=a[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"),n.classList.remove("visible"),a.classList.remove("wptb-preview-table-manage-cells");var l=a.getElementsByTagName("td");if(0<l.length)for(var o=0;o<l.length;o++)l[o].classList.remove("wptb-highlighted")}else document.select.activateMultipleSelectMode(),e[r].classList.add("visible"),t.classList.add("visible"),n.classList.add("visible"),a.classList.add("wptb-preview-table-manage-cells")},w.recalculateIndexes=function(e){for(var t=this.getElementsByTagName("tr"),n=void 0,a=0,r=[],l=document.getElementById("wptb-top-row-as-header"),o=0;o<t.length;o++){0==o?(null==e&&(t[o].style.backgroundColor=jQuery("#wptb-table-header-bg").val()),l.checked?null==e&&(this.classList.add("wptb-table-preview-head"),t[o].classList.add("wptb-table-head")):null==e&&(this.classList.remove("wptb-table-preview-head"),t[o].classList.remove("wptb-table-head"))):(o%2==0?null==e&&(t[o].style.backgroundColor=jQuery("#wptb-odd-row-bg").val()):null==e&&(t[o].style.backgroundColor=jQuery("#wptb-even-row-bg").val()),t[o].classList.remove("wptb-table-head")),r[o],n=t[o].getElementsByTagName("td"),null==r[o]&&(r[o]=[]);for(var s=0,i=0;i<n.length;i++){if(null!=r[o][i])for(var d=0;d<100;d++){if(null==r[o][s]){r[o][s]=n[i],n[i].dataset.xIndex=s;break}s++}else r[o][i]=n[i],n[i].dataset.xIndex=s;if(n[i].dataset.yIndex=o,1<n[i].colSpan)for(var c=1;c<n[i].colSpan;c++)s++,r[o][s]="tdDummy";if(1<n[i].rowSpan)for(var m=1;m<n[i].rowSpan;m++){null==r[o+m]&&(r[o+m]=[]);for(var p=0;p<n[i].colSpan;p++)r[o+m][s-n[i].colSpan+1+p]="tdDummy"}s++}a<i&&(a=i)}this.columns=a},w.addColumnEnd=function(){var e=void 0,t=document.getElementsByClassName("wptb-preview-table"),n=void 0,a=void 0;0<t.length&&(n=t[0].querySelector("td")),n&&(a=n.getAttribute("style"));for(var r=0;r<w.rows.length;r++)e=new WPTB_Cell(E),a&&e.getDOMElement().setAttribute("style",a),w.rows[r].appendChild(e.getDOMElement()),array[r].push(0);f++,w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.addColumnStart=function(){var e=void 0,t=void 0,n=document.getElementsByClassName("wptb-preview-table"),a=void 0,r=void 0;0<n.length&&(a=n[0].querySelector("td")),a&&(r=a.getAttribute("style"));for(var l=0;l<w.rows.length;l++)e=new WPTB_Cell(E),r&&e.getDOMElement().setAttribute("style",r),(t=w.rows[l].getElementsByTagName("td")[0])?w.rows[l].insertBefore(e.getDOMElement(),t):w.rows[l].appendChild(e.getDOMElement()),array[l].push(0);f++,w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.addColumnAfter=function(e){var t=w.rows,n=void 0,a=void 0,r=document.querySelector(".wptb-highlighted"),l=r.getAttribute("style"),o=null!=e&&"number"==typeof e?e:N(r)[1];if(f-o-r.colSpan+1==1)w.addColumnEnd();else{for(var s=!1,i=void 0,d=void 0,c=void 0,m=[],p=void 0,u=0;u<f;u++)m.push(0);for(u=0;u<t.length;u++){n=0,a=t[u].getElementsByTagName("td"),s=!1;for(var b=0;b<f;b+=i){if(i=1,s){d=new WPTB_Cell(E),l&&d.getDOMElement().setAttribute("style",l),p&&t[u].contains(p)?(c=p.nextSibling)?t[u].insertBefore(d.getDOMElement(),c):t[u].appendChild(d.getDOMElement()):t[u].insertBefore(d.getDOMElement(),a[0]);break}if(0<m[b])o==b&&(s=!0);else if(1<(p=a[n++]).rowSpan){i=p.colSpan;for(var g=0;g<p.colSpan;g++)m[b+g]=p.rowSpan,b+g==o&&(s=!0)}else if(1<p.colSpan){i=p.colSpan;for(g=0;g<p.colSpan;g++)b+g==o&&(s=!0)}else b==o&&(s=!0)}for(var y=0;y<f;y++)0<m[y]&&m[y]--}for(u=0;u<array.length;u++)array[u].push(0);f++,T(array),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()}},w.addColumnBefore=function(){var e=document.querySelector(".wptb-highlighted"),t=N(e)[1];0===t?w.addColumnStart():w.addColumnAfter(t-1)},w.addRowToTheEnd=function(){var e,t=w.insertRow(-1),n=void 0,a=document.getElementsByClassName("wptb-preview-table"),r=void 0,l=void 0;t.classList.add("wptb-row"),0<a.length&&(r=a[0].querySelector("td")),r&&(l=r.getAttribute("style"));for(var o=0;o<f;o++)n=new WPTB_Cell(E),l&&n.getDOMElement().setAttribute("style",l),t.appendChild(n.getDOMElement());e=Array.from(array[0]),array.push(e),T(array),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.addRowToTheStart=function(){var e,t=w.insertRow(0),n=void 0,a=document.getElementsByClassName("wptb-preview-table"),r=void 0,l=void 0;t.classList.add("wptb-row"),0<a.length&&(r=a[0].querySelector("td")),r&&(l=r.getAttribute("style"));for(var o=0;o<f;o++)n=new WPTB_Cell(E),l&&n.getDOMElement().setAttribute("style",l),t.appendChild(n.getDOMElement());e=Array.from(array[0]),array.push(e),T(array),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.addRowBefore=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),n=N(e)[0],a=void 0,r=n-1;0<=r;r--){var l=w.rows[r].children,o=l.length;if(0<o)for(var s=0;s<o;s++)if(1==l[s].rowSpan){n=r,a=!0;break}if(a)break}0===n?w.addRowToTheStart():w.addRowAfter(n,t)},w.addRowAfter=function(e,t){var n,a=void 0;if(null!=e&&"number"==typeof e||null!=t)a=e;else{var r=document.querySelector(".wptb-highlighted");t=r.getAttribute("style"),a=(e=N(r)[0])+r.rowSpan-1}var l=0;if(a<w.rows.length-1){for(var o=0;o<=a;o++){var s=w.rows[o].children,i=s.length;if(0<i)for(var d=0;d<i;d++){a<s[d].rowSpan-1+o&&s[d].rowSpan++}}var c=w.rows[a+1].children,m=c.length;if(0<m)for(var p=0;p<m;p++)l+=c[p].colSpan}else l=array[0].length;var u=w.insertRow(a+1);for(u.classList.add("wptb-row"),g=0;g<l;g++){var b=new WPTB_Cell(E);b.getDOMElement().setAttribute("style",t),u.appendChild(b.getDOMElement())}n=Array.from(array[0]),array.push(n),T(array),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.isSquare=function(e){for(var t,n,a=-1,r=-1,l=-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<r||-1==r)&&(r=d),(i<a||-1==a)&&(a=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),l<i&&(l=i));for(i=a;i<l;i++)for(d=r;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=l-a+1)*(n=o-r+1)===s&&[t,n]},w.mergeCells=function(){for(var e=w.isSquare(array),t=e[0],n=e[1],a=document.querySelector(".wptb-highlighted"),r=[].slice.call(document.getElementsByClassName("wptb-highlighted"),1),l=[],o=0;o<r.length;o++){var s=r[o].getElementsByClassName("wptb-ph-element");if(0<s.length)for(var i=s.length,d=0;d<i;d++)l.push(s[d]);r[o].parentNode.removeChild(r[o])}if(0<l.length)for(var c=0;c<l.length;c++)a.appendChild(l[c]);a.colSpan=n,a.rowSpan=t,w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.splitCell=function(){var e=document.getElementsByClassName("wptb-highlighted")[0],t=e.rowSpan,n=e.colSpan,a=e.getAttribute("style"),r=N(e)[0],l=w.rows[r],o=e.dataset.xIndex;e.rowSpan=1;for(var s=e.colSpan=1;s<n;s++){var i=new WPTB_Cell(E);i.getDOMElement().setAttribute("style",a),e.nextSibling?l.insertBefore(i.getDOMElement(),e.nextSibling):l.appendChild(i.getDOMElement())}if(1<t)for(var d=1;d<t;d++){var c=void 0,m=w.rows[r+d],p=m.children,u=p.length;if(0<u)for(var b=0;b<u;b++)if(Number(p[b].dataset.xIndex)>Number(o)){c=p[b];break}for(var g=0;g<n;g++){var y=new WPTB_Cell(E);y.getDOMElement().setAttribute("style",a),null!=c?m.insertBefore(y.getDOMElement(),c):m.appendChild(y.getDOMElement())}}w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w),C()},w.findRowspannedCells=function(e){var t,n=[];if(actualPoints=function(e){for(var t=w.rows[e].getElementsByTagName("td"),n=0,a=0;a<t.length;a++)n+=t[a].colSpan;return n}(e),actualPoints===f)return[];t=f-actualPoints;for(var a=e-1;0<=a&&t;a--){var r=w.rows[a].getElementsByTagName("td");for(a=0;a<r.length;a++)1<r[a].rowSpan&&(n.push(r[a]),t-=r[a].colSpan)}return n},w.addLackingCells=function(){for(var e=[],t=0;t<w.rows.length;t++)e.push(0);for(t=0;t<w.rows.length;t++)for(var n=w.rows[t].getElementsByTagName("td"),a=0;a<n.length;a++)if(1<n[a].rowSpan)for(var r=1;r<n[a].rowSpan;r++)e[t+r]++;for(t=0;t<w.rows.length;t++){n=w.rows[t].getElementsByTagName("td");var l=0;for(a=0;a<n.length;a++)l+=n[a].colSpan;l+=e[t],difference=f-l;for(a=0;a<difference;a++){var o=new WPTB_Cell(E);w.rows[t].appendChild(o.getDOMElement())}}},w.deleteRow=function(){var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),n=e.rowSpan,a=N(e)[0],r=void 0;null==n&&(n=1);for(var l=0;l<n;l++){var o=w.rows[a].children,s=w.rows[a+1],i=void 0,d=void 0,c=[];if(null!=s){d=(i=s.children).length;for(var m=0;m<o.length;m++)if(1<o[m].rowSpan){var p=new WPTB_Cell(E);p.getDOMElement().setAttribute("style",t),p.getDOMElement().colSpan=o[m].colSpan,p.getDOMElement().rowSpan=o[m].rowSpan-1;for(var u=void 0,b=0;b<d;b++)if(Number(i[b].dataset.xIndex)>Number(o[m].dataset.xIndex)){u=i[b];break}u?c.push([p,u]):c.push([p])}if(0<c.length)for(var g=0;g<c.length;g++)null!=c[g][1]?s.insertBefore(c[g][0].getDOMElement(),c[g][1]):s.appendChild(c[g][0].getDOMElement())}var y=w.rows;if(0<y.length)for(var f=0;f<a;f++){var v=y[f].children;if(0<v.length)for(var h=0;h<v.length;h++)v[h].rowSpan-1>=a-f&&v[h].rowSpan--}r=Array.from(array[0]),array.pop(r),T(array),w.getElementsByTagName("tbody")[0].removeChild(w.rows[a]),0==w.rows.length&&(w.toggleTableEditMode(),B.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w)}C()},w.deleteColumn=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.dataset.xIndex,n=e.colSpan,a=0;a<n;a++){for(var r=0;r<w.rows.length;r++){var l=w.rows[r].children,o=l.length;if(0<o)for(var s=o-1;0<=s;s--){if(Number(l[s].dataset.xIndex)==Number(t)){1<l[s].colSpan?l[s].colSpan--:w.rows[r].removeChild(l[s]);break}if(Number(l[s].dataset.xIndex)<Number(t)&&Number(l[s].dataset.xIndex)+Number(l[s].colSpan-1)>=t){1<l[s].colSpan&&l[s].colSpan--;break}}}for(var i=0;i<w.rows.length;i++)null!=array[i]&&array[i].pop();f--,0==w.querySelectorAll("td").length&&(w.toggleTableEditMode(),B.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),w.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(w)}C()},document.getElementsByClassName("wptb-table-generator")[0].style.display="none",array=function(){for(var e=[],t=[],n=0;n<w.rows.length;n++){for(var a=w.rows[n].getElementsByTagName("td"),r=0,l=0;l<a.length;l++)r+=a[l].colSpan;e.push(r)}f=Math.max.apply(null,e);var o=w.rows.length;for(n=0;n<o;n++)for(t[n]=[],l=0;l<f;l++)t[n].push(0);return T(t),t}(),C(),T(array),B.appendChild(w),w.recalculateIndexes(!0),WPTB_LeftPanel()};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var WPTB_Text=function(e,t){var n=document.createElement("div"),a=document.createElement("div"),r=document.createElement("p"),l=void 0,o=!1;if(n.classList.add("wptb-text-container"),r.innerHTML=null!=e?e:"Text",a.appendChild(r),n.appendChild(a),t){var s=t.className.match(/wptb-element-((.+-)\d+)/i);s&&Array.isArray(s)&&(l=s[1],o=!0);for(var i=[].concat(_toConsumableArray(t.attributes)),d=0;d<i.length;d++)n.setAttribute(i[d].name,i[d].value)}return this.kind="text",this.getDOMElement=function(){return n},applyGenericItemSettings(this,l,o),this},WPTB_innerElementSet=function m(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("ondragenter"))},t.ondragover=function(e){e.preventDefault(),WPTB_DropHandle(this,e)},t.ondragleave=function(){},t.ondrop=function(e){this.classList.remove("ondragenter");var t=void 0,n=void 0;if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.getData("wptbElement")||e.dataTransfer.getData("node")){var a,r=void 0,l=void 0;if(0<document.getElementsByClassName("wptb-drop-handle").length&&(r=document.getElementsByClassName("wptb-drop-handle")[0]),0<document.getElementsByClassName("wptb-drop-border-marker").length&&(l=document.getElementsByClassName("wptb-drop-border-marker")[0]),e.dataTransfer.getData("wptbElement")?t=(t="list"==(a=e.dataTransfer.getData("wptbElement"))?new WPTB_List:"image"==a?new WPTB_Image:"text"==a?new WPTB_Text:"button"==a?new WPTB_Button:void 0).getDOMElement():(n=e.dataTransfer.getData("node"),(t=document.getElementsByClassName(n)[0]).classList.remove("wptb-moving-mode")),"block"==r.style.display){var o=void 0;if("Drop Here"==r.dataset.text)(o=r.getDOMParentElement()).appendChild(t);else{var s=r.getDOMParentElement();if(o=s.parentNode,"Abowe Element"==r.dataset.text)o.insertBefore(t,s);else if("Below Element"==r.dataset.text){var i=s.nextSibling;o.insertBefore(t,i)}}var d=o.parentNode;if(d.classList.contains("wptb-table-head")){var c=WPTB_Helper.findAncestor(d,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(c)}return r.style.display="none",l.style.display="none",m(t),!0}}},t.onmouseover=function(e){t.classList.remove("ondragenter")}},applyGenericItemSettings=function(p,e){var t,u,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],b=p.getDOMElement();if(null==e||1==n){t=document.counter.nextIndex(p.kind);for(var a=document.getElementsByClassName("wptb-ph-element"),r=[],l=0;l<a.length;l++){var o=new RegExp("wptb-element-"+p.kind+"-(\\d+)","i"),s=a[l].className.match(o);s&&r.push(s[1])}if(0<r.length)t=Math.max.apply(Math,r)+1;else t=1}else e&&!n&&(t=e.split("-")[1]);if(b.onmouseenter=function(e){this.classList.add("wptb-directlyhovered");var t=document.createElement("span"),n=document.createElement("span"),a=document.createElement("span"),r=document.createElement("span");r.classList.add("wptb-actions"),t.classList.add("dashicons","dashicons-trash","wptb-delete-action"),n.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),a.classList.add("dashicons","dashicons-move","wptb-move-action"),a.draggable=!0,t.onclick=function(e){var t=this.parentNode.parentNode,n=t.parentNode;if(n.removeChild(t),"text"==t.kind){var a=n.parentNode;if(a.classList.contains("wptb-table-head")){var r=WPTB_Helper.findAncestor(a,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(r)}}},n.onclick=function(e){var t=void 0;if("list"==p.kind){e.target.parentNode.parentNode.parentNode;for(var n=[],a=e.target.parentNode.parentNode.querySelectorAll("ul li .wptb-list-item-content"),r=0;r<a.length;r++)n.push(a[r].innerHTML);t=new WPTB_List(n,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else if("text"==p.kind){e.target.parentNode.parentNode.parentNode;t=new WPTB_Text(e.target.parentNode.parentNode.childNodes[0].innerHTML,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else if("image"==p.kind){e.target.parentNode.parentNode.parentNode;t=new WPTB_Image(e.target.parentNode.parentNode.children[0].children[0].src,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}else{e.target.parentNode.parentNode.parentNode;var l=e.target.parentNode.parentNode.childNodes[0].querySelector("p").innerHTML;t=new WPTB_Button(l,b),b.parentNode.insertBefore(t.getDOMElement(),b.nextSibling)}WPTB_innerElementSet(t.getDOMElement())};var l,o,s=this;l=s.className.match(/wptb-element-(.+)-(\d+)/i),o=l[1];var i=WPTB_Helper.dragImagesArr();if(a.ondragstart=function(e){if(this.parentNode.style.opacity=0,s.classList.remove("wptb-directlyhovered"),s.classList.add("wptb-moving-mode"),e.dataTransfer.setDragImage(i[o],0,0),e.dataTransfer.setData("node","wptb-element-"+l[1]+"-"+l[2]),e.dataTransfer.setData("wptb-moving-mode","wptb-element-"+l[1]+"-"+l[2]),e.dataTransfer.setData("wptbElIndic-"+l[1],"wptbElIndic-"+l[1]),"text"==e.target.parentNode.parentNode.kind){var t=el.parentNode;if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}}},"button"===p.kind){var d=b.querySelector("a"),c=d.querySelector("div");d.onclick=function(e){e.preventDefault()},WPTB_Helper.buttonsTinyMceInit(c)}else if("text"===p.kind)tinyMCE.init({target:b.childNodes[0],inline:!0,plugins:"link, paste",dialog_type:"modal",theme:"modern",menubar:!1,fixed_toolbar_container:"#wpcd_fixed_toolbar",paste_as_text:!0,toolbar:"bold italic strikethrough link unlink | alignleft aligncenter alignright alignjustify",setup:function(e){e.on("change",function(e){var t=WPTB_Helper.findAncestor(b,"wptb-row");if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}})},init_instance_callback:function(e){(window.currentEditor=e).on("focus",function(e){var t=document.getElementsByClassName("wptb-builder-panel")[0].offsetWidth;window.currentEditor&&55<=document.getElementById("wptb_builder").scrollTop&&"none"!=window.currentEditor.bodyElement.style.display?(document.getElementById("wpcd_fixed_toolbar").style.position="fixed",document.getElementById("wpcd_fixed_toolbar").style.right=t/2-document.getElementById("wpcd_fixed_toolbar").offsetWidth/2+"px",document.getElementById("wpcd_fixed_toolbar").style.top="100px"):(document.getElementById("wpcd_fixed_toolbar").style.position="static",delete document.getElementById("wpcd_fixed_toolbar").style.right,delete document.getElementById("wpcd_fixed_toolbar").style.top)})}});else{u=b.getElementsByClassName("wptb-list-item-content");for(var m=0;m<u.length;m++)WPTB_Helper.listItemsTinyMceInit(u[m])}r.appendChild(a),r.appendChild(n),r.appendChild(t),this.appendChild(r)},b.onmouseleave=function(e){this.classList.remove("wptb-directlyhovered");for(var t=0;e.target.querySelector(".wptb-actions")&&t<5;)e.target.querySelector(".wptb-actions").remove(),t++},"text"==p.kind){new MutationObserver(function(e){var t=WPTB_Helper.findAncestor(b,"wptb-row");if(t.classList.contains("wptb-table-head")){var n=WPTB_Helper.findAncestor(t,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(n)}}).observe(p.getDOMElement(),{attributes:!0,attributeFilter:["style"]})}var i=b.className.match(/wptb-element-(.+)-(\d+)/i);i&&b.classList.remove(i[0]),b.classList.contains("wptb-ph-element")||b.classList.add("wptb-ph-element"),b.classList.contains("wptb-element-"+p.kind+"-"+t)||b.classList.add("wptb-element-"+p.kind+"-"+t),new WPTB_ElementOptions(p,t,e),document.counter.increment(p.kind)};
inc/admin/js/core/WPTB_Cell.js CHANGED
@@ -116,6 +116,39 @@ var WPTB_Cell = function (callback, DOMElement) {
116
  this.appendElement = function (node) {
117
  getDOMElement().appendChild(node);
118
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  return this;
121
  };
116
  this.appendElement = function (node) {
117
  getDOMElement().appendChild(node);
118
  };
119
+
120
+ DOMElement.getCellDimensions = function() {
121
+ let tdStyleObj = window.getComputedStyle( this, null );
122
+
123
+ let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );
124
+ let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );
125
+
126
+ let tdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );
127
+ let tdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );
128
+
129
+ let tdPaddingTop = tdStyleObj.getPropertyValue( 'padding-top' );
130
+ let tdPaddingBottom = tdStyleObj.getPropertyValue( 'padding-bottom' );
131
+
132
+ let tdBorderTopWidth = tdStyleObj.getPropertyValue( 'border-top-width' );
133
+ let tdBorderBottomWidth = tdStyleObj.getPropertyValue( 'border-bottom-width' );
134
+
135
+ let width = parseFloat( this.offsetWidth, 10 ) -
136
+ parseFloat( tdPaddingLeft, 10 ) -
137
+ parseFloat( tdPaddingRight, 10 ) -
138
+ parseFloat( tdBorderLeftWidth, 10 ) -
139
+ parseFloat( tdBorderRightWidth, 10 );
140
+
141
+ let height = parseFloat( this.offsetHeight, 10 ) -
142
+ parseFloat( tdPaddingTop, 10 ) -
143
+ parseFloat( tdPaddingBottom, 10 ) -
144
+ parseFloat( tdBorderTopWidth, 10 ) -
145
+ parseFloat( tdBorderBottomWidth, 10 );
146
+
147
+ return {
148
+ width: width,
149
+ height: height
150
+ };
151
+ }
152
 
153
  return this;
154
  };
inc/admin/js/core/WPTB_Helper.js CHANGED
@@ -166,7 +166,6 @@ var WPTB_Helper = {
166
  for( let j = 0; j < tdElements.length; j++ ) {
167
  let element = tdElements[j];
168
  if( element.classList.contains( 'wptb-ph-element' ) ) {
169
- let textContentStyle = element.getAttribute( 'style' );
170
  let infArr = element.className.match( /wptb-element-(.+)-(\d+)/i );
171
  if( infArr[1] == 'text' ) {
172
  let p = element.querySelector( 'p' ),
@@ -253,5 +252,27 @@ var WPTB_Helper = {
253
  if (!results) return false;
254
  if (!results[2]) return '';
255
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
  }
166
  for( let j = 0; j < tdElements.length; j++ ) {
167
  let element = tdElements[j];
168
  if( element.classList.contains( 'wptb-ph-element' ) ) {
 
169
  let infArr = element.className.match( /wptb-element-(.+)-(\d+)/i );
170
  if( infArr[1] == 'text' ) {
171
  let p = element.querySelector( 'p' ),
252
  if (!results) return false;
253
  if (!results[2]) return '';
254
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
255
+ },
256
+ getColumnWidth: function( table, cell ) {
257
+ let xIndex = cell.dataset.xIndex;
258
+ let xIndexes = table.querySelectorAll( '[data-x-index="' + xIndex + '"]' );
259
+ let cellWidth = cell.getCellDimensions().width;
260
+ for( let i = 0; i < xIndexes.length; i++ ) {
261
+ if( cellWidth > xIndexes[i].getCellDimensions().width ) {
262
+ cellWidth = xIndexes[i].getCellDimensions().width;
263
+ }
264
+ }
265
+ return cellWidth;
266
+ },
267
+ getRowHeight: function( table, cell ) {
268
+ let yIndex = cell.dataset.yIndex;
269
+ let yIndexes = table.querySelectorAll( '[data-y-index="' + yIndex + '"]' );
270
+ let cellHeight = cell.getCellDimensions().height;
271
+ for( let i = 0; i < yIndexes.length; i++ ) {
272
+ if( cellHeight > yIndexes[i].getCellDimensions().height ) {
273
+ cellHeight = yIndexes[i].getCellDimensions().height;
274
+ }
275
+ }
276
+ return cellHeight;
277
  }
278
  }
inc/admin/js/core/WPTB_LeftPanel.js CHANGED
@@ -178,7 +178,7 @@ var WPTB_LeftPanel = function () {
178
  }
179
  }
180
 
181
- function addInnerBorder(checked) {
182
  var styles, color = document.querySelector('#wptb-table-border-color').value != undefined ?
183
  document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';
184
  if ( document.querySelector( '#wptb-table-inner-border-slider' ).value == 0 || document.querySelector( '#wptb-table-inner-border-number' ).value == 0 ) {
@@ -200,13 +200,14 @@ var WPTB_LeftPanel = function () {
200
  var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );
201
  for (var i = 0; i < tableCells.length; i++) {
202
  tableCells[i].style.border = '0px solid ' + color;
 
203
  }
204
  }
205
  }
206
 
207
  }
208
 
209
- function addBorderSize(value) {
210
  table.style.borderWidth = value + 'px';
211
  table.style.borderStyle = 'solid';
212
  }
@@ -272,21 +273,30 @@ var WPTB_LeftPanel = function () {
272
  let wptbImageWidthNumber = document.getElementById( 'wptb-image-width-number' );
273
  numberImputSize( wptbImageWidthNumber, 2, 100 );
274
 
 
 
 
 
 
 
275
 
276
 
277
  document.getElementById('wptb-table-cell-slider').oninput = function () {
278
  document.getElementById('wptb-table-cell-number').value = this.value;
279
  addCellPadding(this.value);
 
280
  };
281
 
282
  document.getElementById('wptb-table-cell-number').onchange = function () {
283
  document.getElementById('wptb-table-cell-slider').value = this.value;
284
  addCellPadding(this.value);
 
285
  };
286
 
287
  document.getElementById('wptb-table-border-slider').oninput = function () {
288
  document.getElementById('wptb-table-border-number').value = this.value;
289
  addBorderSize(this.value);
 
290
 
291
  let wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,
292
  tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );
@@ -300,16 +310,19 @@ var WPTB_LeftPanel = function () {
300
  document.getElementById('wptb-table-border-number').onchange = function () {
301
  document.getElementById('wptb-table-border-slider').value = this.value;
302
  addBorderSize(this.value);
 
303
  };
304
 
305
  document.getElementById('wptb-table-inner-border-slider').oninput = function () {
306
  document.getElementById('wptb-table-inner-border-number').value = this.value;
307
  addInnerBorderSize(this.value);
 
308
  };
309
 
310
  document.getElementById('wptb-table-inner-border-number').onchange = function () {
311
  document.getElementById('wptb-table-inner-border-slider').value = this.value;
312
  addInnerBorderSize(this.value);
 
313
  };
314
 
315
  document.getElementById('wptb-inner-border-check').onchange = function () {
@@ -327,6 +340,54 @@ var WPTB_LeftPanel = function () {
327
 
328
  };
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  function createMobileHeadForTable( table, thisEvent ) {
331
 
332
  if( thisEvent.checked ) {
178
  }
179
  }
180
 
181
+ function addInnerBorder( checked ) {
182
  var styles, color = document.querySelector('#wptb-table-border-color').value != undefined ?
183
  document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';
184
  if ( document.querySelector( '#wptb-table-inner-border-slider' ).value == 0 || document.querySelector( '#wptb-table-inner-border-number' ).value == 0 ) {
200
  var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );
201
  for (var i = 0; i < tableCells.length; i++) {
202
  tableCells[i].style.border = '0px solid ' + color;
203
+ tableCells[i].style.border = null;
204
  }
205
  }
206
  }
207
 
208
  }
209
 
210
+ function addBorderSize( value ) {
211
  table.style.borderWidth = value + 'px';
212
  table.style.borderStyle = 'solid';
213
  }
273
  let wptbImageWidthNumber = document.getElementById( 'wptb-image-width-number' );
274
  numberImputSize( wptbImageWidthNumber, 2, 100 );
275
 
276
+ let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );
277
+ numberImputSize( wptbTableColumnWidthNumber, 2, 500 );
278
+
279
+ let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );
280
+ numberImputSize( wptbTableRowHeightNumber, 2, 200 );
281
+
282
 
283
 
284
  document.getElementById('wptb-table-cell-slider').oninput = function () {
285
  document.getElementById('wptb-table-cell-number').value = this.value;
286
  addCellPadding(this.value);
287
+ table.tdDefaultWidth();
288
  };
289
 
290
  document.getElementById('wptb-table-cell-number').onchange = function () {
291
  document.getElementById('wptb-table-cell-slider').value = this.value;
292
  addCellPadding(this.value);
293
+ table.tdDefaultWidth();
294
  };
295
 
296
  document.getElementById('wptb-table-border-slider').oninput = function () {
297
  document.getElementById('wptb-table-border-number').value = this.value;
298
  addBorderSize(this.value);
299
+ table.tdDefaultWidth();
300
 
301
  let wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,
302
  tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );
310
  document.getElementById('wptb-table-border-number').onchange = function () {
311
  document.getElementById('wptb-table-border-slider').value = this.value;
312
  addBorderSize(this.value);
313
+ table.tdDefaultWidth();
314
  };
315
 
316
  document.getElementById('wptb-table-inner-border-slider').oninput = function () {
317
  document.getElementById('wptb-table-inner-border-number').value = this.value;
318
  addInnerBorderSize(this.value);
319
+ table.tdDefaultWidth();
320
  };
321
 
322
  document.getElementById('wptb-table-inner-border-number').onchange = function () {
323
  document.getElementById('wptb-table-inner-border-slider').value = this.value;
324
  addInnerBorderSize(this.value);
325
+ table.tdDefaultWidth();
326
  };
327
 
328
  document.getElementById('wptb-inner-border-check').onchange = function () {
340
 
341
  };
342
 
343
+ document.getElementById( 'wptb-table-column-width-slider' ).oninput = function () {
344
+ document.getElementById( 'wptb-table-column-width-number' ).value = this.value;
345
+ table.addColumnWidth( this.value );
346
+ };
347
+
348
+ document.getElementById( 'wptb-table-column-width-number' ).onchange = function () {
349
+ document.getElementById( 'wptb-table-column-width-slider' ).value = this.value;
350
+ table.addColumnWidth( this.value );
351
+ };
352
+
353
+ document.getElementById( 'wptb-table-column-width-auto-fixed' ).onchange = function () {
354
+ if( this.checked ) {
355
+ let highlighted = table.querySelector( '.wptb-highlighted' );
356
+ let width = WPTB_Helper.getColumnWidth( table, highlighted );
357
+ table.addColumnWidth( width );
358
+ } else {
359
+ table.addColumnWidth( false, true );
360
+ let highlighted = table.querySelector( '.wptb-highlighted' );
361
+ let width = WPTB_Helper.getColumnWidth( table, highlighted );
362
+ document.getElementById( 'wptb-table-column-width-number' ).value = width;
363
+ document.getElementById( 'wptb-table-column-width-slider' ).value = width;
364
+ }
365
+ };
366
+
367
+ document.getElementById( 'wptb-table-row-height-slider' ).oninput = function () {
368
+ document.getElementById( 'wptb-table-row-height-number' ).value = this.value;
369
+ table.addRowHeight( this.value );
370
+ };
371
+
372
+ document.getElementById( 'wptb-table-row-height-number' ).onchange = function () {
373
+ document.getElementById( 'wptb-table-row-height-slider' ).value = this.value;
374
+ table.addRowHeight( this.value );
375
+ };
376
+
377
+ document.getElementById( 'wptb-table-row-height-auto-fixed' ).onchange = function () {
378
+ if( this.checked ) {
379
+ let highlighted = table.querySelector( '.wptb-highlighted' );
380
+ let height = WPTB_Helper.getRowHeight( table, highlighted );
381
+ table.addRowHeight( height );
382
+ } else {
383
+ table.addRowHeight( false, true );
384
+ let highlighted = table.querySelector( '.wptb-highlighted' );
385
+ let height = WPTB_Helper.getRowHeight( table, highlighted );
386
+ document.getElementById( 'wptb-table-row-height-number' ).value = height;
387
+ document.getElementById( 'wptb-table-row-height-slider' ).value = height;
388
+ }
389
+ };
390
+
391
  function createMobileHeadForTable( table, thisEvent ) {
392
 
393
  if( thisEvent.checked ) {
inc/admin/js/core/WPTB_Stringifier.js CHANGED
@@ -3,19 +3,14 @@ var WPTB_Stringifier = function ( codeMain ) {
3
  let code = codeMain.cloneNode( true );
4
  code.classList.add( 'wptb-table-preview-static-indic' );
5
  code.dataset.tableColumns = codeMain.columns;
6
- code.dataset.reconstraction = 1;
 
 
7
 
8
  let tds = code.getElementsByTagName( 'td' );
9
  if ( tds.length > 0 ) {
10
  for ( let i = 0; i < tds.length; i++ ) {
11
 
12
- for( let i = 0; i < tds.length; i++ ) {
13
- if( code.dataset.reconstraction == 1 && tds[i].colSpan > 1 || tds[i].rowSpan > 1 ) {
14
- code.dataset.reconstraction = 0;
15
- break;
16
- }
17
- }
18
-
19
  if ( codeMain.querySelector( 'wptb-table-preview-head' ) ) {
20
  tds[i].removeAttribute( 'data-x-index' );
21
  }
3
  let code = codeMain.cloneNode( true );
4
  code.classList.add( 'wptb-table-preview-static-indic' );
5
  code.dataset.tableColumns = codeMain.columns;
6
+ code.style.width = null;
7
+ code.style.minWidth = null;
8
+ code.style.maxWidth = null;
9
 
10
  let tds = code.getElementsByTagName( 'td' );
11
  if ( tds.length > 0 ) {
12
  for ( let i = 0; i < tds.length; i++ ) {
13
 
 
 
 
 
 
 
 
14
  if ( codeMain.querySelector( 'wptb-table-preview-head' ) ) {
15
  tds[i].removeAttribute( 'data-x-index' );
16
  }
inc/admin/js/core/WPTB_Table.js CHANGED
@@ -16,17 +16,18 @@ var array = [], WPTB_Table = function (columns, rows) {
16
  * It too toggles the bits of our abstract representation.
17
  * @param Event this is the event instance of the click performed over a cell.
18
  */
19
- var mark = function (event) {
20
  var rs = this.rowSpan,
21
- cs = this.colSpan,
22
- markedCells,
23
- noCells = document.getElementsByClassName('wptb-no-cell-action'),
24
- singleCells = document.getElementsByClassName('wptb-single-action'),
25
- multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),
26
- position = getCoords(this),
27
- row = position[0],
28
- column = position[1];
29
- if (!document.select.isActivated()) {
 
30
  return;
31
  }
32
  if (this.className.match(/wptb-highlighted/)) {
@@ -59,6 +60,7 @@ var array = [], WPTB_Table = function (columns, rows) {
59
  singleCells[i].classList.remove('visible');
60
  singleCells[i].setAttribute('disabled', 'disabled');
61
  }
 
62
  } else if (markedCells === 1) {
63
  for (var i = 0; i < multipleCells.length; i++) {
64
  multipleCells[i].classList.remove('visible');
@@ -72,6 +74,48 @@ var array = [], WPTB_Table = function (columns, rows) {
72
  singleCells[i].classList.add('visible');
73
  singleCells[i].removeAttribute('disabled');
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  } else {
76
  for (var i = 0; i < multipleCells.length; i++) {
77
  if (table.isSquare(array)) {
@@ -90,6 +134,7 @@ var array = [], WPTB_Table = function (columns, rows) {
90
  singleCells[i].classList.remove('visible');
91
  singleCells[i].setAttribute('disabled', 'disabled');
92
  }
 
93
  }
94
  };
95
 
@@ -341,9 +386,9 @@ var array = [], WPTB_Table = function (columns, rows) {
341
  }
342
 
343
  //Create a HTML Table element.
344
- table = document.createElement('table');
345
- table.classList.add('wptb-preview-table');
346
-
347
  //Add the data rows.
348
  for (var i = 0; i < rows; i++) {
349
 
@@ -381,31 +426,33 @@ var array = [], WPTB_Table = function (columns, rows) {
381
  let bar = document.getElementsByClassName('wptb-edit-bar'),
382
  cellModeBackground = document.getElementById('wptb-cell_mode_background'),
383
  leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
 
384
  wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
385
  if (wptbPreviewTable.length > 0) {
386
  wptbPreviewTable = wptbPreviewTable[0];
387
  }
388
 
389
- if (bar.length > 0) {
390
- for (let i = 0; i < bar.length; i++) {
391
- if (bar[i].classList.contains('visible')) {
392
  document.select.deactivateMultipleSelectMode();
393
- bar[i].classList.remove('visible');
394
- cellModeBackground.classList.remove('visible');
395
- leftScrollPanelCurtain.classList.remove('visible');
396
- wptbPreviewTable.classList.remove('wptb-preview-table-manage-cells');
397
- let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');
398
- if (wptbPreviewTableTds.length > 0) {
399
- for (let i = 0; i < wptbPreviewTableTds.length; i++) {
400
- wptbPreviewTableTds[i].classList.remove('wptb-highlighted');
 
401
  }
402
  }
403
  } else {
404
  document.select.activateMultipleSelectMode();
405
- bar[i].classList.add('visible');
406
- cellModeBackground.classList.add('visible');
407
- leftScrollPanelCurtain.classList.add('visible');
408
- wptbPreviewTable.classList.add('wptb-preview-table-manage-cells');
409
  }
410
  }
411
 
@@ -418,7 +465,7 @@ var array = [], WPTB_Table = function (columns, rows) {
418
  */
419
 
420
  table.recalculateIndexes = function ( start ) {
421
- let trs = this.getElementsByTagName('tr'), tds, maxCols = 0,
422
  tdsArr = [];
423
  let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );
424
 
@@ -495,12 +542,304 @@ var array = [], WPTB_Table = function (columns, rows) {
495
  }
496
  }
497
  jMainIter++;
 
 
 
498
  }
499
  if (j > maxCols) {
500
  maxCols = j;
501
  }
502
  }
503
  this.columns = maxCols;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
505
 
506
  /*
@@ -508,9 +847,9 @@ var array = [], WPTB_Table = function (columns, rows) {
508
  */
509
  table.addColumnEnd = function () {
510
  let td,
511
- currentTable = document.getElementsByClassName('wptb-preview-table'),
512
- currentTableTd,
513
- currentTdStyle;
514
  if (currentTable.length > 0) {
515
  currentTableTd = currentTable[0].querySelector('td');
516
  }
@@ -518,16 +857,23 @@ var array = [], WPTB_Table = function (columns, rows) {
518
  if (currentTableTd) {
519
  currentTdStyle = currentTableTd.getAttribute('style');
520
  }
 
521
  for (var i = 0; i < table.rows.length; i++) {
522
  td = new WPTB_Cell(mark);
 
523
  if (currentTdStyle) {
524
  td.getDOMElement().setAttribute('style', currentTdStyle);
 
525
  }
 
526
  table.rows[i].appendChild(td.getDOMElement());
527
  array[i].push(0);
528
  }
 
529
  maxAmountOfCells++;
530
  table.recalculateIndexes();
 
 
531
  WPTB_Helper.dataTitleColumnSet( table );
532
  undoSelect();
533
  };
@@ -538,21 +884,23 @@ var array = [], WPTB_Table = function (columns, rows) {
538
 
539
  table.addColumnStart = function () {
540
  let td,
541
- firstCell,
542
- currentTable = document.getElementsByClassName('wptb-preview-table'),
543
- currentTableTd,
544
- currentTdStyle;
545
- if (currentTable.length > 0) {
546
  currentTableTd = currentTable[0].querySelector('td');
547
  }
548
 
549
- if (currentTableTd) {
550
  currentTdStyle = currentTableTd.getAttribute('style');
551
  }
 
552
  for (var i = 0; i < table.rows.length; i++) {
553
  td = new WPTB_Cell(mark);
554
  if (currentTdStyle) {
555
  td.getDOMElement().setAttribute('style', currentTdStyle);
 
556
  }
557
  firstCell = table.rows[i].getElementsByTagName('td')[0];
558
  if (firstCell) {
@@ -565,6 +913,8 @@ var array = [], WPTB_Table = function (columns, rows) {
565
 
566
  maxAmountOfCells++;
567
  table.recalculateIndexes();
 
 
568
  WPTB_Helper.dataTitleColumnSet( table );
569
  undoSelect();
570
  };
@@ -612,6 +962,7 @@ var array = [], WPTB_Table = function (columns, rows) {
612
  td = new WPTB_Cell(mark);
613
  if (cellStyle) {
614
  td.getDOMElement().setAttribute('style', cellStyle);
 
615
  }
616
  if (currentCell && rows[i].contains(currentCell)) {
617
  bro = currentCell.nextSibling;
@@ -665,6 +1016,8 @@ var array = [], WPTB_Table = function (columns, rows) {
665
  maxAmountOfCells++;
666
  drawTable(array);
667
  table.recalculateIndexes();
 
 
668
  WPTB_Helper.dataTitleColumnSet( table );
669
  undoSelect();
670
  }
@@ -720,6 +1073,7 @@ var array = [], WPTB_Table = function (columns, rows) {
720
  array.push(aux);
721
  drawTable(array);
722
  table.recalculateIndexes();
 
723
  WPTB_Helper.dataTitleColumnSet( table );
724
  undoSelect();
725
  };
@@ -756,6 +1110,7 @@ var array = [], WPTB_Table = function (columns, rows) {
756
  array.push(aux);
757
  drawTable(array);
758
  table.recalculateIndexes();
 
759
  WPTB_Helper.dataTitleColumnSet( table );
760
  undoSelect();
761
  };
@@ -856,6 +1211,8 @@ var array = [], WPTB_Table = function (columns, rows) {
856
  for ( j = 0; j < cellsColSpan; j++ ) {
857
  let td = new WPTB_Cell( mark );
858
  td.getDOMElement().setAttribute( 'style', cellStyle );
 
 
859
  r.appendChild( td.getDOMElement() );
860
  }
861
 
@@ -863,6 +1220,7 @@ var array = [], WPTB_Table = function (columns, rows) {
863
  array.push(aux);
864
  drawTable(array);
865
  table.recalculateIndexes();
 
866
  WPTB_Helper.dataTitleColumnSet( table );
867
  undoSelect();
868
  };
@@ -972,6 +1330,26 @@ var array = [], WPTB_Table = function (columns, rows) {
972
  first.colSpan = colspan;
973
  first.rowSpan = rowspan;
974
  table.recalculateIndexes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
975
  WPTB_Helper.dataTitleColumnSet( table );
976
  undoSelect();
977
  };
@@ -998,6 +1376,7 @@ var array = [], WPTB_Table = function (columns, rows) {
998
  for (let i = 1; i < colspan; i++) {
999
  let td = new WPTB_Cell(mark);
1000
  td.getDOMElement().setAttribute('style', cellStyles);
 
1001
  if ( cell.nextSibling ) {
1002
  thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );
1003
  } else {
@@ -1034,6 +1413,9 @@ var array = [], WPTB_Table = function (columns, rows) {
1034
  }
1035
 
1036
  table.recalculateIndexes();
 
 
 
1037
  WPTB_Helper.dataTitleColumnSet( table );
1038
  undoSelect();
1039
  };
@@ -1247,6 +1629,7 @@ var array = [], WPTB_Table = function (columns, rows) {
1247
  }
1248
 
1249
  table.recalculateIndexes();
 
1250
  WPTB_Helper.dataTitleColumnSet( table );
1251
  }
1252
  undoSelect();
@@ -1263,6 +1646,12 @@ var array = [], WPTB_Table = function (columns, rows) {
1263
  //if (columns || rows) {
1264
  table.recalculateIndexes( true );
1265
  //}
 
 
 
 
 
 
1266
 
1267
  WPTB_LeftPanel();
1268
 
16
  * It too toggles the bits of our abstract representation.
17
  * @param Event this is the event instance of the click performed over a cell.
18
  */
19
+ var mark = function ( event ) {
20
  var rs = this.rowSpan,
21
+ cs = this.colSpan,
22
+ markedCells,
23
+ noCells = document.getElementsByClassName('wptb-no-cell-action'),
24
+ singleCells = document.getElementsByClassName('wptb-single-action'),
25
+ multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),
26
+ cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),
27
+ position = getCoords(this),
28
+ row = position[0],
29
+ column = position[1];
30
+ if ( ! document.select.isActivated() ) {
31
  return;
32
  }
33
  if (this.className.match(/wptb-highlighted/)) {
60
  singleCells[i].classList.remove('visible');
61
  singleCells[i].setAttribute('disabled', 'disabled');
62
  }
63
+ cellSettings.classList.remove( 'visible' );
64
  } else if (markedCells === 1) {
65
  for (var i = 0; i < multipleCells.length; i++) {
66
  multipleCells[i].classList.remove('visible');
74
  singleCells[i].classList.add('visible');
75
  singleCells[i].removeAttribute('disabled');
76
  }
77
+ let cellHighlighted = document.querySelector( '.wptb-highlighted' );
78
+ if( cellHighlighted ) {
79
+ let wptbTableColumnWidthSlider = document.getElementById( 'wptb-table-column-width-slider' );
80
+ let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );
81
+ let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );
82
+ let width = cellHighlighted.style.width;
83
+ if( width ) {
84
+ wptbTableColumnWidthSlider.value = parseFloat( width, 10 );
85
+ wptbTableColumnWidthNumber.value = parseFloat( width, 10 );
86
+ tableColumnWidthAutoFixedCheckbox.checked = true;
87
+ } else if( cellHighlighted.dataset.wptbFixedWidth ) {
88
+ wptbTableColumnWidthSlider.value = cellHighlighted.dataset.wptbFixedWidth;
89
+ wptbTableColumnWidthNumber.value = cellHighlighted.dataset.wptbFixedWidth;
90
+ tableColumnWidthAutoFixedCheckbox.checked = true;
91
+ } else {
92
+ let cellWidth = WPTB_Helper.getColumnWidth( table, cellHighlighted );
93
+ wptbTableColumnWidthSlider.value = cellWidth;
94
+ wptbTableColumnWidthNumber.value = cellWidth;
95
+ tableColumnWidthAutoFixedCheckbox.checked = false;
96
+ }
97
+
98
+
99
+ let wptbTableRowHeightSlider = document.getElementById( 'wptb-table-row-height-slider' );
100
+ let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );
101
+ let tableRowHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );
102
+ let height = cellHighlighted.style.height;
103
+ if( height ) {
104
+ wptbTableRowHeightSlider.value = parseFloat( height, 10 );
105
+ wptbTableRowHeightNumber.value = parseFloat( height, 10 );
106
+ tableRowHeightAutoFixedCheckbox.checked = true;
107
+ } else if( cellHighlighted.dataset.wptbFixedHeight ) {
108
+ wptbTableRowHeightSlider.value = cellHighlighted.dataset.wptbFixedHeight;
109
+ wptbTableRowHeightNumber.value = cellHighlighted.dataset.wptbFixedHeight;
110
+ tableRowHeightAutoFixedCheckbox.checked = true;
111
+ } else {
112
+ let cellHeight = WPTB_Helper.getRowHeight( table, cellHighlighted );
113
+ wptbTableRowHeightSlider.value = cellHeight;
114
+ wptbTableRowHeightNumber.value = cellHeight;
115
+ tableRowHeightAutoFixedCheckbox.checked = false;
116
+ }
117
+ }
118
+ cellSettings.classList.add( 'visible' );
119
  } else {
120
  for (var i = 0; i < multipleCells.length; i++) {
121
  if (table.isSquare(array)) {
134
  singleCells[i].classList.remove('visible');
135
  singleCells[i].setAttribute('disabled', 'disabled');
136
  }
137
+ cellSettings.classList.remove( 'visible' );
138
  }
139
  };
140
 
386
  }
387
 
388
  //Create a HTML Table element.
389
+ table = document.createElement( 'table' );
390
+ table.classList.add( 'wptb-preview-table', 'wptb-preview-table-default-width' );
391
+ table.dataset.reconstraction = 1;
392
  //Add the data rows.
393
  for (var i = 0; i < rows; i++) {
394
 
426
  let bar = document.getElementsByClassName('wptb-edit-bar'),
427
  cellModeBackground = document.getElementById('wptb-cell_mode_background'),
428
  leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
429
+ leftScrollPanelCellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),
430
  wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
431
  if (wptbPreviewTable.length > 0) {
432
  wptbPreviewTable = wptbPreviewTable[0];
433
  }
434
 
435
+ if ( bar.length > 0 ) {
436
+ for ( let i = 0; i < bar.length; i++ ) {
437
+ if ( bar[i].classList.contains( 'visible' ) ) {
438
  document.select.deactivateMultipleSelectMode();
439
+ bar[i].classList.remove( 'visible' );
440
+ cellModeBackground.classList.remove( 'visible' );
441
+ leftScrollPanelCurtain.classList.remove( 'visible' );
442
+ leftScrollPanelCellSettings.classList.remove( 'visible' );
443
+ wptbPreviewTable.classList.remove( 'wptb-preview-table-manage-cells' );
444
+ let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName( 'td' );
445
+ if ( wptbPreviewTableTds.length > 0 ) {
446
+ for ( let i = 0; i < wptbPreviewTableTds.length; i++ ) {
447
+ wptbPreviewTableTds[i].classList.remove( 'wptb-highlighted' );
448
  }
449
  }
450
  } else {
451
  document.select.activateMultipleSelectMode();
452
+ bar[i].classList.add( 'visible' );
453
+ cellModeBackground.classList.add( 'visible' );
454
+ leftScrollPanelCurtain.classList.add( 'visible' );
455
+ wptbPreviewTable.classList.add( 'wptb-preview-table-manage-cells' );
456
  }
457
  }
458
 
465
  */
466
 
467
  table.recalculateIndexes = function ( start ) {
468
+ let trs = this.getElementsByTagName('tr'), tds, maxCols = 0, maxColsFull = 0,
469
  tdsArr = [];
470
  let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );
471
 
542
  }
543
  }
544
  jMainIter++;
545
+ if( i == 0 ) {
546
+ maxColsFull = jMainIter;
547
+ }
548
  }
549
  if (j > maxCols) {
550
  maxCols = j;
551
  }
552
  }
553
  this.columns = maxCols;
554
+ this.maxCols = maxColsFull;
555
+ }
556
+
557
+ table.addColumnWidth = function( value, cleaner ) {
558
+ let highlighted = table.getElementsByClassName( 'wptb-highlighted' );
559
+ if( highlighted.length > 0 ) {
560
+ for( let k = 0; k < highlighted.length; k++ ) {
561
+ let dataXIndex = highlighted[k].dataset.xIndex;
562
+ if( dataXIndex ) {
563
+ function tableTdsFor( dataXIndex, colspan ) {
564
+ let tableRows = table.rows;
565
+ let widthIsSet = false;
566
+ let arrayTdsFromPreviousRow = [];
567
+ for( let i = 0; i < tableRows.length; i++ ) {
568
+ let row = tableRows[i];
569
+ let tds = row.children;
570
+ for( let j = 0; j < tds.length; j++ ) {
571
+ let td = tds[j];
572
+ if( td.dataset.xIndex == dataXIndex ) {
573
+ if( value ) {
574
+ if( td.colSpan == colspan ) {
575
+ td.style.width = value + 'px';
576
+ td.removeAttribute( 'data-wptb-fixed-width' );
577
+ widthIsSet = true;
578
+ let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );
579
+ if( ! tableColumnWidthAutoFixedCheckbox.checked ) {
580
+ tableColumnWidthAutoFixedCheckbox.checked = true;
581
+ }
582
+ } else {
583
+ td.style.width = null;
584
+ td.dataset.wptbFixedWidth = value;
585
+ if( i == tableRows.length - 1 && ! widthIsSet ) {
586
+ tableTdsFor( dataXIndex, colspan + 1 );
587
+ }
588
+ }
589
+ } else if( cleaner ) {
590
+ td.style.width = null;
591
+ td.removeAttribute( 'data-wptb-fixed-width' );
592
+ } else {
593
+ if( td.dataset.wptbFixedWidth ) {
594
+ if( td.colSpan == colspan ) {
595
+ td.style.width = td.dataset.wptbFixedWidth + 'px';
596
+ td.removeAttribute( 'data-wptb-fixed-width' );
597
+ }
598
+ } else if( td.style.width ) {
599
+ for( let z = 0; z < arrayTdsFromPreviousRow.length; z++ ) {
600
+ arrayTdsFromPreviousRow[z].style.width = td.style.width;
601
+ }
602
+ arrayTdsFromPreviousRow = [];
603
+ } else {
604
+ arrayTdsFromPreviousRow.push( td );
605
+ }
606
+ }
607
+ break;
608
+ }
609
+ }
610
+ }
611
+ }
612
+
613
+ tableTdsFor( dataXIndex, 1 );
614
+ }
615
+ }
616
+
617
+ table.tdDefaultWidth();
618
+ }
619
+ }
620
+
621
+ table.tdDefaultWidth = function() {
622
+ let rows = table.rows;
623
+
624
+ let tableTdsSumMaxWidth = 0;
625
+ let tableTdsSumMaxWidthFixed = 0;
626
+ let tableTdsSumMaxWidthAuto = 0;
627
+
628
+ let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' )[0];
629
+ let wptbTableSetupWidth = wptbTableSetup.offsetWidth;
630
+
631
+ let arrayCellsWidthFixedHelper = [];
632
+ let arrayCellsWidthAutoHelper = [];
633
+ let tdPaddingCommon = 0;
634
+ let tableTdBorderCommonWidth = 0;
635
+ let cssForTdsWidthAuto = '';
636
+
637
+ for( let i = 0; i < rows.length; i++ ) {
638
+ let tds = rows[i].children;
639
+ for( let j = 0; j < tds.length; j++ ) {
640
+ let td = tds[j];
641
+
642
+ if( ! arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] && ! arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] ) {
643
+ if( td.style.width ) {
644
+ arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] = parseFloat( td.style.width );
645
+ td.removeAttribute( 'data-wptb-css-td-auto-width' );
646
+ } else {
647
+ if( ! td.dataset.wptbFixedWidth ) {
648
+ arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] = 100;
649
+ td.dataset.wptbCssTdAutoWidth = true;
650
+ }
651
+ }
652
+
653
+ if( window.getComputedStyle( td, null ) ) {
654
+ let tdStyleObj = window.getComputedStyle( td, null );
655
+ let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );
656
+ let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );
657
+ tdPaddingCommon = parseFloat( tdPaddingLeft, 10 ) + parseFloat( tdPaddingRight, 10 );
658
+
659
+ let tableTdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );
660
+ let tableTdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );
661
+ tableTdBorderCommonWidth = parseFloat( tableTdBorderLeftWidth, 10 ) + parseFloat( tableTdBorderRightWidth, 10 );
662
+ if( arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] ) {
663
+ arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] += tdPaddingCommon;
664
+ arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] += tableTdBorderCommonWidth;
665
+ } else {
666
+ arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] += tdPaddingCommon;
667
+ arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] += tableTdBorderCommonWidth;
668
+ }
669
+ }
670
+ } else if( arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] ) {
671
+ if( ! td.dataset.wptbFixedWidth ) {
672
+ td.dataset.wptbCssTdAutoWidth = true;
673
+ }
674
+ } else if( arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] ) {
675
+ td.removeAttribute( 'data-wptb-css-td-auto-width' );
676
+ }
677
+ }
678
+ }
679
+
680
+ for( let i = 0; i < arrayCellsWidthFixedHelper.length; i++ ) {
681
+ if( arrayCellsWidthFixedHelper[i] ) {
682
+ tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[i];
683
+ }
684
+ }
685
+
686
+ let CellsWidthAutoCount = 0;
687
+ for( let i = 0; i < arrayCellsWidthAutoHelper.length; i++ ) {
688
+ if( arrayCellsWidthAutoHelper[i] ) {
689
+ tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[i];
690
+ CellsWidthAutoCount++;
691
+ }
692
+ }
693
+
694
+ let tableFullStyleObj = window.getComputedStyle( table, null );
695
+ let borderLeftWidth = tableFullStyleObj.getPropertyValue( 'border-left-width' );
696
+ let borderRightWidth = tableFullStyleObj.getPropertyValue( 'border-right-width' );
697
+ let tableBorderCommon = parseFloat( borderLeftWidth, 10 ) + parseFloat( borderRightWidth, 10 );
698
+ tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto + tableBorderCommon;
699
+
700
+ table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;
701
+ if( CellsWidthAutoCount ) {
702
+ table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;
703
+ if( table.mergingСellsHorizontally ) {
704
+ table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed - tableBorderCommon;
705
+ } else {
706
+ table.removeAttribute( 'data-wptb-fixed-width-size' );
707
+ }
708
+ } else {
709
+ table.removeAttribute( 'data-wptb-fixed-width-size' );
710
+ table.removeAttribute( 'data-wptb-cells-width-auto-count' );
711
+ }
712
+
713
+ let styleElementCreate = false;
714
+ let tableTdWidthAuto;
715
+ if( tableTdsSumMaxWidth < wptbTableSetupWidth ) {
716
+ if( CellsWidthAutoCount ) {
717
+ table.style.minWidth = '100%';
718
+ if( table.mergingСellsHorizontally ) {
719
+ table.style.width = null;
720
+ let tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed - tableBorderCommon;
721
+ tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
722
+ tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
723
+ styleElementCreate = true;
724
+ } else {
725
+ table.style.width = '100%';
726
+ }
727
+ } else {
728
+ table.style.width = null;
729
+ table.style.minWidth = null;
730
+ table.style.maxWidth = tableTdsSumMaxWidth + 'px';
731
+ }
732
+ } else {
733
+ table.style.maxWidth = null;
734
+ table.style.minWidth = tableTdsSumMaxWidth + 'px';
735
+ table.style.width = null;
736
+ tableTdWidthAuto = '100'
737
+ styleElementCreate = true;
738
+ }
739
+
740
+ let head = document.head;
741
+ if( head ) {
742
+ let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width="true"]' );
743
+ if( cssForTdsWidthAutoOld ) {
744
+ head.removeChild( cssForTdsWidthAutoOld );
745
+ }
746
+ }
747
+
748
+ if( styleElementCreate ) {
749
+ cssForTdsWidthAuto = document.createElement( 'style' );
750
+ cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );
751
+ cssForTdsWidthAuto.innerHTML = '[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';
752
+ if( head ) {
753
+ head.appendChild( cssForTdsWidthAuto );
754
+ }
755
+ }
756
+ }
757
+
758
+ table.addRowHeight = function( value, cleaner ) {
759
+ let highlighted = table.getElementsByClassName( 'wptb-highlighted' );
760
+ if( highlighted.length > 0 ) {
761
+ for( let k = 0; k < highlighted.length; k++ ) {
762
+ let dataYIndex = highlighted[k].dataset.yIndex;
763
+ if( dataYIndex ) {
764
+ function tableTdsFor( dataYIndex, rowspan ) {
765
+ let tableRows = table.rows;
766
+ let heightIsSet = false;
767
+ let arrayTdsPrevious = [];
768
+ for( let i = 0; i < tableRows.length; i++ ) {
769
+ let row = tableRows[i];
770
+ let tds = row.children;
771
+ for( let j = 0; j < tds.length; j++ ) {
772
+ let td = tds[j];
773
+ if( td.dataset.yIndex == dataYIndex ) {
774
+ if( value ) {
775
+ if( td.rowSpan == rowspan ) {
776
+ td.style.height = value + 'px';
777
+ td.removeAttribute( 'data-wptb-fixed-heidht' );
778
+ heightIsSet = true;
779
+ let tableColumnHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );
780
+ if( ! tableColumnHeightAutoFixedCheckbox.checked ) {
781
+ tableColumnHeightAutoFixedCheckbox.checked = true;
782
+ }
783
+ continue;
784
+ } else {
785
+ td.style.height = null;
786
+ td.dataset.wptbFixedHeight = value;
787
+ if( j == tds.length - 1 && ! heightIsSet ) {
788
+ tableTdsFor( dataYIndex , rowspan + 1 );
789
+ }
790
+ }
791
+ } else if( cleaner ) {
792
+ td.style.height = null;
793
+ td.removeAttribute( 'data-wptb-fixed-heidht' );
794
+ } else {
795
+ if( td.dataset.wptbFixedHeight ) {
796
+ if( td.rowSpan = rowspan ) {
797
+ td.style.height = td.dataset.wptbFixedHeight + 'px';
798
+ td.removeAttribute( 'data-wptb-fixed-width' );
799
+ }
800
+ } else if( td.style.height ) {
801
+ for( let z = 0; z < arrayTdsPrevious.length; z++ ) {
802
+ arrayTdsPrevious[z].style.height = td.style.height;
803
+ }
804
+ arrayTdsPrevious = [];
805
+ } else {
806
+ arrayTdsPrevious.push( td );
807
+ }
808
+ }
809
+ }
810
+ }
811
+ }
812
+ }
813
+
814
+ tableTdsFor( dataYIndex, 1 );
815
+ }
816
+ }
817
+ }
818
+ }
819
+
820
+ table.reconstraction = function() {
821
+ let tds = table.getElementsByTagName( 'td' );
822
+ table.mergingСellsHorizontally = false;
823
+ table.mergingCellsVertically = false;
824
+ table.dataset.reconstraction = 1;
825
+ let forBreak = 0;
826
+ for( let i = 0; i < tds.length; i++ ) {
827
+ if( tds[i].colSpan > 1 ) {
828
+ table.dataset.reconstraction = 0;
829
+ table.mergingСellsHorizontally = true;
830
+ forBreak++;
831
+ }
832
+
833
+ if( tds[i].rowSpan > 1 ) {
834
+ table.dataset.reconstraction = 0;
835
+ table.mergingCellsVertically = true;
836
+ forBreak++;
837
+ }
838
+
839
+ if( forBreak == 2 ) {
840
+ break;
841
+ }
842
+ }
843
  }
844
 
845
  /*
847
  */
848
  table.addColumnEnd = function () {
849
  let td,
850
+ currentTable = document.getElementsByClassName('wptb-preview-table'),
851
+ currentTableTd,
852
+ currentTdStyle;
853
  if (currentTable.length > 0) {
854
  currentTableTd = currentTable[0].querySelector('td');
855
  }
857
  if (currentTableTd) {
858
  currentTdStyle = currentTableTd.getAttribute('style');
859
  }
860
+
861
  for (var i = 0; i < table.rows.length; i++) {
862
  td = new WPTB_Cell(mark);
863
+
864
  if (currentTdStyle) {
865
  td.getDOMElement().setAttribute('style', currentTdStyle);
866
+ td.getDOMElement().style.width = null;
867
  }
868
+
869
  table.rows[i].appendChild(td.getDOMElement());
870
  array[i].push(0);
871
  }
872
+
873
  maxAmountOfCells++;
874
  table.recalculateIndexes();
875
+ table.tdDefaultWidth();
876
+ table.addRowHeight();
877
  WPTB_Helper.dataTitleColumnSet( table );
878
  undoSelect();
879
  };
884
 
885
  table.addColumnStart = function () {
886
  let td,
887
+ firstCell,
888
+ currentTable = document.getElementsByClassName('wptb-preview-table'),
889
+ currentTableTd,
890
+ currentTdStyle;
891
+ if ( currentTable.length > 0 ) {
892
  currentTableTd = currentTable[0].querySelector('td');
893
  }
894
 
895
+ if ( currentTableTd ) {
896
  currentTdStyle = currentTableTd.getAttribute('style');
897
  }
898
+
899
  for (var i = 0; i < table.rows.length; i++) {
900
  td = new WPTB_Cell(mark);
901
  if (currentTdStyle) {
902
  td.getDOMElement().setAttribute('style', currentTdStyle);
903
+ td.getDOMElement().style.width = null;
904
  }
905
  firstCell = table.rows[i].getElementsByTagName('td')[0];
906
  if (firstCell) {
913
 
914
  maxAmountOfCells++;
915
  table.recalculateIndexes();
916
+ table.tdDefaultWidth();
917
+ table.addRowHeight();
918
  WPTB_Helper.dataTitleColumnSet( table );
919
  undoSelect();
920
  };
962
  td = new WPTB_Cell(mark);
963
  if (cellStyle) {
964
  td.getDOMElement().setAttribute('style', cellStyle);
965
+ td.getDOMElement().style.width = null;
966
  }
967
  if (currentCell && rows[i].contains(currentCell)) {
968
  bro = currentCell.nextSibling;
1016
  maxAmountOfCells++;
1017
  drawTable(array);
1018
  table.recalculateIndexes();
1019
+ table.addColumnWidth();
1020
+ table.addRowHeight();
1021
  WPTB_Helper.dataTitleColumnSet( table );
1022
  undoSelect();
1023
  }
1073
  array.push(aux);
1074
  drawTable(array);
1075
  table.recalculateIndexes();
1076
+ table.addColumnWidth();
1077
  WPTB_Helper.dataTitleColumnSet( table );
1078
  undoSelect();
1079
  };
1110
  array.push(aux);
1111
  drawTable(array);
1112
  table.recalculateIndexes();
1113
+ table.addColumnWidth();
1114
  WPTB_Helper.dataTitleColumnSet( table );
1115
  undoSelect();
1116
  };
1211
  for ( j = 0; j < cellsColSpan; j++ ) {
1212
  let td = new WPTB_Cell( mark );
1213
  td.getDOMElement().setAttribute( 'style', cellStyle );
1214
+ td.getDOMElement().style.width = null;
1215
+ td.getDOMElement().style.height = null;
1216
  r.appendChild( td.getDOMElement() );
1217
  }
1218
 
1220
  array.push(aux);
1221
  drawTable(array);
1222
  table.recalculateIndexes();
1223
+ table.addColumnWidth();
1224
  WPTB_Helper.dataTitleColumnSet( table );
1225
  undoSelect();
1226
  };
1330
  first.colSpan = colspan;
1331
  first.rowSpan = rowspan;
1332
  table.recalculateIndexes();
1333
+ table.reconstraction();
1334
+ let firstWidth = first.style.width;
1335
+ let firstDataFixedWidth = first.dataset.wptbFixedWidth;
1336
+ if( firstWidth ) {
1337
+ table.addColumnWidth( parseFloat( firstWidth, 10 ) );
1338
+ } else if( firstDataFixedWidth ) {
1339
+ table.addColumnWidth();
1340
+ } else {
1341
+ table.addColumnWidth( false, true );
1342
+ }
1343
+
1344
+ let firstHeight = first.style.height;
1345
+ let firstDataFixedHeight = first.dataset.wptbFixedHeight;
1346
+ if( firstHeight ) {
1347
+ table.addRowHeight( parseFloat( firstHeight, 10 ) );
1348
+ } else if( firstDataFixedHeight ) {
1349
+ table.addRowHeight();
1350
+ } else {
1351
+ table.addRowHeight( false, true );
1352
+ }
1353
  WPTB_Helper.dataTitleColumnSet( table );
1354
  undoSelect();
1355
  };
1376
  for (let i = 1; i < colspan; i++) {
1377
  let td = new WPTB_Cell(mark);
1378
  td.getDOMElement().setAttribute('style', cellStyles);
1379
+ td.getDOMElement().classList.add( 'wptb-highlighted' );
1380
  if ( cell.nextSibling ) {
1381
  thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );
1382
  } else {
1413
  }
1414
 
1415
  table.recalculateIndexes();
1416
+ table.reconstraction();
1417
+ table.addColumnWidth();
1418
+ table.addRowHeight();
1419
  WPTB_Helper.dataTitleColumnSet( table );
1420
  undoSelect();
1421
  };
1629
  }
1630
 
1631
  table.recalculateIndexes();
1632
+ table.tdDefaultWidth();
1633
  WPTB_Helper.dataTitleColumnSet( table );
1634
  }
1635
  undoSelect();
1646
  //if (columns || rows) {
1647
  table.recalculateIndexes( true );
1648
  //}
1649
+ table.reconstraction();
1650
+ table.tdDefaultWidth();
1651
+
1652
+ wptbTableSetup.onresize = function() {
1653
+ table.tdDefaultWidth();
1654
+ };
1655
 
1656
  WPTB_LeftPanel();
1657
 
inc/admin/views/builder/wptb-builder-left-panel.php CHANGED
@@ -290,12 +290,69 @@ use WP_Table_Builder as NS;
290
  <button id="wptb-left-scroll-panel-curtain-close" class="wptb-table_change_button" title="<?php esc_attr_e( 'Close Manage Cells Mode', 'wp-table-builder' );?>"><?php esc_html_e( 'Close', 'wp-table-builder' ); ?></button>
291
  </div>
292
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  <a href="javascript:void(0)" class="wptb-left-panel-extend" data-fn="togglePanel" data-title-collapsed="Expand panel" data-title-expanded="Collapse panel" title="Collapse panel">
294
  <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="512" height="512" viewBox="0 0 357 357" style="enable-background:new 0 0 357 357;" xml:space="preserve" class=""><g transform="matrix(-1, 1.22465e-16, -1.22465e-16, -1, 357, 357)"><g>
295
  <g id="play-arrow">
296
  <polygon points="38.25,0 38.25,357 318.75,178.5 " data-original="#000000" class="active-path" style="fill:#3B7EC0" data-old_color="##3B7EC"></polygon>
297
  </g>
298
- </g></g>
299
  </svg>
300
  </a>
301
  </div>
290
  <button id="wptb-left-scroll-panel-curtain-close" class="wptb-table_change_button" title="<?php esc_attr_e( 'Close Manage Cells Mode', 'wp-table-builder' );?>"><?php esc_html_e( 'Close', 'wp-table-builder' ); ?></button>
291
  </div>
292
  </div>
293
+ <div id="wptb-left-scroll-panel-cell-settings">
294
+ <div class="wptb-settings-section">
295
+ <div class="wptb-settings-dropdown">
296
+ Cell Settings
297
+ </div>
298
+ <div class="wptb-settings-items">
299
+ <div class="wptb-settings-item-header">
300
+ <p style="margin: 0">
301
+ <?php esc_html_e( 'Column Width', 'wp-table-builder' ); ?>
302
+ </p>
303
+ </div>
304
+ <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
305
+ <div class="wptb-settings-col-xs-8">
306
+ <input id="wptb-table-column-width-slider" type="range" min="50" max="500" step="1" value="30">
307
+ </div>
308
+ <div class="wptb-settings-col-xs-4">
309
+ <input id="wptb-table-column-width-number" class="wptb-number-input" type="number" min="50" max="500" step="1" placeholder="30" pattern="[0-9]*">
310
+ <span class="wptb-input-px">px</span>
311
+ </div>
312
+ <div class="wptb-settings-col-xs-12">
313
+ <label class="wptb-checkbox-button wptb-column-width-fix-auto">
314
+ <input id="wptb-table-column-width-auto-fixed" type="checkbox" />
315
+ <i>
316
+ <div class="wptb-column-fixed"><?php esc_html_e( 'Fixed', 'wp-table-builder' ); ?></div>
317
+ <div class="wptb-column-auto"><?php esc_html_e( 'Auto', 'wp-table-builder' ); ?></div>
318
+ </i>
319
+ </label>
320
+ </div>
321
+ </div>
322
+ </div>
323
+ <div class="wptb-settings-items">
324
+ <div class="wptb-settings-item-header">
325
+ <p style="margin: 0">
326
+ <?php esc_html_e( 'Row Height', 'wp-table-builder' ); ?>
327
+ </p>
328
+ </div>
329
+ <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
330
+ <div class="wptb-settings-col-xs-8">
331
+ <input id="wptb-table-row-height-slider" type="range" min="10" max="200" step="1" value="10">
332
+ </div>
333
+ <div class="wptb-settings-col-xs-4">
334
+ <input id="wptb-table-row-height-number" class="wptb-number-input" type="number" min="10" max="200" step="1" placeholder="10" pattern="[0-9]*">
335
+ <span class="wptb-input-px">px</span>
336
+ </div>
337
+ <div class="wptb-settings-col-xs-12">
338
+ <label class="wptb-checkbox-button wptb-column-width-fix-auto">
339
+ <input id="wptb-table-row-height-auto-fixed" type="checkbox" />
340
+ <i>
341
+ <div class="wptb-column-fixed"><?php esc_html_e( 'Fixed', 'wp-table-builder' ); ?></div>
342
+ <div class="wptb-column-auto"><?php esc_html_e( 'Auto', 'wp-table-builder' ); ?></div>
343
+ </i>
344
+ </label>
345
+ </div>
346
+ </div>
347
+ </div>
348
+ </div>
349
+ </div>
350
  <a href="javascript:void(0)" class="wptb-left-panel-extend" data-fn="togglePanel" data-title-collapsed="Expand panel" data-title-expanded="Collapse panel" title="Collapse panel">
351
  <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="512" height="512" viewBox="0 0 357 357" style="enable-background:new 0 0 357 357;" xml:space="preserve" class=""><g transform="matrix(-1, 1.22465e-16, -1.22465e-16, -1, 357, 357)"><g>
352
  <g id="play-arrow">
353
  <polygon points="38.25,0 38.25,357 318.75,178.5 " data-original="#000000" class="active-path" style="fill:#3B7EC0" data-old_color="##3B7EC"></polygon>
354
  </g>
355
+ </g></g>
356
  </svg>
357
  </a>
358
  </div>
inc/admin/views/builder/wptb-builder-table-settings.php CHANGED
@@ -6,7 +6,7 @@
6
 
7
  <div class="wptb-settings-items" style="display: block;">
8
  <div class="wptb-settings-row wptb-settings-middle-xs">
9
- <div class="wptb-settings-col-xs-12" style="margin: auto;">
10
  <input type="button" id="wptb-activate-cell-management-mode" name="wptb-activate-cell-management-mode"
11
  class="wptb-button" value="<?php esc_attr_e( 'Manage Cells', 'wp_table_builder' ); ?>"
12
  title="<?php esc_attr_e( 'Manage Cells', 'wp_table_builder' ); ?>">
@@ -79,10 +79,10 @@
79
  </div>
80
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
81
  <div class="wptb-settings-col-xs-8">
82
- <input id="wptb-table-cell-slider" type="range" min="10" max="50" step="1" value="15">
83
  </div>
84
  <div class="wptb-settings-col-xs-4">
85
- <input id="wptb-table-cell-number" class="wptb-number-input" type="number" min="10" max="50" step="1" placeholder="15" pattern="[0-9]*">
86
  <span class="wptb-input-px">px</span>
87
  </div>
88
  </div>
6
 
7
  <div class="wptb-settings-items" style="display: block;">
8
  <div class="wptb-settings-row wptb-settings-middle-xs">
9
+ <div class="wptb-settings-col-xs-12" style="margin: auto; text-align: center;">
10
  <input type="button" id="wptb-activate-cell-management-mode" name="wptb-activate-cell-management-mode"
11
  class="wptb-button" value="<?php esc_attr_e( 'Manage Cells', 'wp_table_builder' ); ?>"
12
  title="<?php esc_attr_e( 'Manage Cells', 'wp_table_builder' ); ?>">
79
  </div>
80
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
81
  <div class="wptb-settings-col-xs-8">
82
+ <input id="wptb-table-cell-slider" type="range" min="0" max="50" step="1" value="15">
83
  </div>
84
  <div class="wptb-settings-col-xs-4">
85
+ <input id="wptb-table-cell-number" class="wptb-number-input" type="number" min="0" max="50" step="1" placeholder="15" pattern="[0-9]*">
86
  <span class="wptb-input-px">px</span>
87
  </div>
88
  </div>
inc/frontend/css/wp-table-builder-frontend.css CHANGED
@@ -3,34 +3,44 @@
3
  *
4
  * The file is enqueued from inc/frontend/class-frontend.php.
5
  */
 
6
  .wptb-table-container {
7
  /*max-width: 850px;*/
8
  overflow: auto;
9
  position: relative;
10
  width: 100%;
11
  min-width: 100%;
 
12
  }
13
 
14
  .wptb-table-container table {
15
  table-layout: fixed;
16
  font-size: 15px;
17
- width: 100%;
18
  display: table;
19
  border-collapse: collapse;
20
  /*min-width: 850px;*/
21
  }
22
 
 
 
 
 
23
  .wptb-table-container-matrix.wptb-matrix-hide {
24
  visibility: visible;
25
  opacity: 0;
26
  position: absolute;
27
- top: 0;
28
  left: 0;
29
  right: 0;
30
  bottom: 0;
31
  z-index: -1;
32
  }
33
 
 
 
 
 
34
  .wptb-preview-table-mobile.wptb-mobile-hide {
35
  display: none;
36
  }
@@ -39,27 +49,33 @@
39
  background-color: #eeeeee;
40
  }
41
 
42
- .wptb-table-container table.wptb-preview-table-mobile tr:nth-of-type(2n+1),
43
  .wptb-table-container table.wptb-preview-table-mobile tr:nth-of-type(2n+1) {
44
  background-color: inherit;
45
  }
46
 
47
- .wptb-table-container table.wptb-preview-table-mobile tr td:nth-of-type(2n+1),
48
  .wptb-table-container table.wptb-preview-table-mobile tr td:nth-of-type(2n+1) {
49
  background-color: #eeeeee;
50
  }
51
 
52
  .wptb-table-container table td {
53
- width: 100px;
54
  box-sizing: content-box;
55
  padding: 15px;
56
  background-color: inherit;
57
  }
58
 
 
 
 
 
59
  .wptb-table-container table td p {
60
  word-wrap: break-word;
61
  overflow-wrap: break-word;
62
  margin: 0 !important;
 
 
63
  }
64
 
65
  .wptb-table-container table tr td ul {
@@ -86,7 +102,8 @@
86
  margin-bottom: 15px;
87
  }
88
 
89
- .wptb-text-container > div, .wptb-text-container > div > p {
 
90
  font-size: inherit;
91
  color: inherit;
92
  }
@@ -172,6 +189,10 @@
172
  margin: 0px 0px 10px;
173
  }
174
 
 
 
 
 
175
  .wptb-list-item-container li p {
176
  word-wrap: break-word;
177
  line-height: 20px;
@@ -225,6 +246,7 @@
225
  top: auto;
226
  bottom: auto;
227
  }
 
228
  .wptb-column-title-mobile-container .wptb-column-title-mobile {
229
  display: table;
230
  width: 100%;
@@ -271,18 +293,17 @@
271
  padding: 0px !important;
272
  }
273
 
274
- .wptb-column-title-mobile-not-elements .wptb-column-title-mobile-container {
275
  position: relative;
276
  width: 50%;
277
  }
278
 
279
- .wptb-column-title-mobile-not-elements .wptb-column-title-mobile-container .wptb-column-title-mobile {
280
  display: block;
281
  min-height: 60px;
282
  }
283
 
284
- .wptb-table-container table.wptb-table-preview-head td.wptb-column-title-mobile-not-elements
285
- .wptb-column-title-mobile-container .wptb-column-title-mobile::before {
286
  display: block;
287
  width: 100%;
288
  padding: 0px;
@@ -355,4 +376,4 @@
355
  .wptb-table-container table.wptb-table-preview-head.wptb-table-preview-static-indic tr.wptb-table-head {
356
  display: none;
357
  }
358
- }
3
  *
4
  * The file is enqueued from inc/frontend/class-frontend.php.
5
  */
6
+
7
  .wptb-table-container {
8
  /*max-width: 850px;*/
9
  overflow: auto;
10
  position: relative;
11
  width: 100%;
12
  min-width: 100%;
13
+ margin: 30px 0;
14
  }
15
 
16
  .wptb-table-container table {
17
  table-layout: fixed;
18
  font-size: 15px;
19
+ width: auto;
20
  display: table;
21
  border-collapse: collapse;
22
  /*min-width: 850px;*/
23
  }
24
 
25
+ .wptb-table-container-matrix table {
26
+ margin: auto;
27
+ }
28
+
29
  .wptb-table-container-matrix.wptb-matrix-hide {
30
  visibility: visible;
31
  opacity: 0;
32
  position: absolute;
33
+ top: 0;
34
  left: 0;
35
  right: 0;
36
  bottom: 0;
37
  z-index: -1;
38
  }
39
 
40
+ table.wptb-preview-table-mobile {
41
+ width: 100%;
42
+ }
43
+
44
  .wptb-preview-table-mobile.wptb-mobile-hide {
45
  display: none;
46
  }
49
  background-color: #eeeeee;
50
  }
51
 
52
+ .wptb-table-container table.wptb-preview-table-mobile tr:nth-of-type(2n+1),
53
  .wptb-table-container table.wptb-preview-table-mobile tr:nth-of-type(2n+1) {
54
  background-color: inherit;
55
  }
56
 
57
+ .wptb-table-container table.wptb-preview-table-mobile tr td:nth-of-type(2n+1),
58
  .wptb-table-container table.wptb-preview-table-mobile tr td:nth-of-type(2n+1) {
59
  background-color: #eeeeee;
60
  }
61
 
62
  .wptb-table-container table td {
63
+ /*width: 100px;*/
64
  box-sizing: content-box;
65
  padding: 15px;
66
  background-color: inherit;
67
  }
68
 
69
+ .wptb-table-container-matrix.wptb-matrix-hide .wptb-preview-table td {
70
+ width: auto !important;
71
+ }
72
+
73
  .wptb-table-container table td p {
74
  word-wrap: break-word;
75
  overflow-wrap: break-word;
76
  margin: 0 !important;
77
+ word-wrap: break-word;
78
+ word-break: break-all;
79
  }
80
 
81
  .wptb-table-container table tr td ul {
102
  margin-bottom: 15px;
103
  }
104
 
105
+ .wptb-text-container>div,
106
+ .wptb-text-container>div>p {
107
  font-size: inherit;
108
  color: inherit;
109
  }
189
  margin: 0px 0px 10px;
190
  }
191
 
192
+ .wptb-list-item-container.wptb-ph-element ul li:last-child {
193
+ margin-bottom: 0;
194
+ }
195
+
196
  .wptb-list-item-container li p {
197
  word-wrap: break-word;
198
  line-height: 20px;
246
  top: auto;
247
  bottom: auto;
248
  }
249
+
250
  .wptb-column-title-mobile-container .wptb-column-title-mobile {
251
  display: table;
252
  width: 100%;
293
  padding: 0px !important;
294
  }
295
 
296
+ .wptb-column-title-mobile-not-elements .wptb-column-title-mobile-container {
297
  position: relative;
298
  width: 50%;
299
  }
300
 
301
+ .wptb-column-title-mobile-not-elements .wptb-column-title-mobile-container .wptb-column-title-mobile {
302
  display: block;
303
  min-height: 60px;
304
  }
305
 
306
+ .wptb-table-container table.wptb-table-preview-head td.wptb-column-title-mobile-not-elements .wptb-column-title-mobile-container .wptb-column-title-mobile::before {
 
307
  display: block;
308
  width: 100%;
309
  padding: 0px;
376
  .wptb-table-container table.wptb-table-preview-head.wptb-table-preview-static-indic tr.wptb-table-head {
377
  display: none;
378
  }
379
+ }
inc/frontend/js/wp-table-builder-frontend.js CHANGED
@@ -135,6 +135,7 @@ jQuery( document ).ready( function ( $ ) {
135
  let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );
136
  if ( wptbPreviewTable.length > 0 ) {
137
  wptbPreviewTable[0].style.display = 'table';
 
138
  wptb_tableReconstraction();
139
  if( wptbPreviewTable[0].classList.contains( 'wptb-table-preview-head' ) ) {
140
  } else {
@@ -144,6 +145,7 @@ jQuery( document ).ready( function ( $ ) {
144
 
145
  //when window resize call wpcd_archiveSectionSmall and wptb_tableGenerateMobile
146
  $( window ).resize( function () {
 
147
  wptb_tableReconstraction();
148
  if( wptbPreviewTable[0].classList.contains( 'wptb-table-preview-head' ) ) {
149
  } else {
@@ -171,6 +173,7 @@ jQuery( document ).ready( function ( $ ) {
171
  tableContainer.style.overflow = 'unset';
172
  if( tableContainerMatrix ) tableContainerMatrix.classList.add( 'wptb-matrix-hide' );
173
 
 
174
  let tableColumns = previewTable.dataset.tableColumns;
175
  if( tableColumns ) {
176
  let tdWidth = previewTableWidth / tableColumns;
@@ -240,6 +243,10 @@ jQuery( document ).ready( function ( $ ) {
240
  tdLeftHeader = previewTable.rows[0].children[j - sectionNumber*tableColumns].cloneNode( true ),
241
  td;
242
  tdLeftHeader.style.backgroundColor = previewTable.rows[0].style.backgroundColor;
 
 
 
 
243
  if( sectionNumber > 0 && j % tableColumns == 0 ) {
244
  tdLeftHeader.style.borderTopWidth = '5px';
245
  }
@@ -249,7 +256,10 @@ jQuery( document ).ready( function ( $ ) {
249
  if( k < previewTable.rows.length ) {
250
  td = previewTable.rows[k].children[j - sectionNumber*tableColumns].cloneNode( true );
251
  td.style.backgroundColor = previewTable.rows[k].style.backgroundColor;
252
- td.style.border
 
 
 
253
  } else {
254
  td = document.createElement( 'td' );
255
  td.style.borderWidth = '0px';
@@ -335,6 +345,10 @@ jQuery( document ).ready( function ( $ ) {
335
  let rowStyles = window.getComputedStyle( row );
336
  newTd.style.backgroundColor = rowStyles.backgroundColor;
337
  }
 
 
 
 
338
  tr.appendChild( newTd );
339
  }
340
 
@@ -359,4 +373,72 @@ jQuery( document ).ready( function ( $ ) {
359
  }
360
  }
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  });
135
  let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );
136
  if ( wptbPreviewTable.length > 0 ) {
137
  wptbPreviewTable[0].style.display = 'table';
138
+ wptb_tdDefaultWidth();
139
  wptb_tableReconstraction();
140
  if( wptbPreviewTable[0].classList.contains( 'wptb-table-preview-head' ) ) {
141
  } else {
145
 
146
  //when window resize call wpcd_archiveSectionSmall and wptb_tableGenerateMobile
147
  $( window ).resize( function () {
148
+ wptb_tdDefaultWidth();
149
  wptb_tableReconstraction();
150
  if( wptbPreviewTable[0].classList.contains( 'wptb-table-preview-head' ) ) {
151
  } else {
173
  tableContainer.style.overflow = 'unset';
174
  if( tableContainerMatrix ) tableContainerMatrix.classList.add( 'wptb-matrix-hide' );
175
 
176
+
177
  let tableColumns = previewTable.dataset.tableColumns;
178
  if( tableColumns ) {
179
  let tdWidth = previewTableWidth / tableColumns;
243
  tdLeftHeader = previewTable.rows[0].children[j - sectionNumber*tableColumns].cloneNode( true ),
244
  td;
245
  tdLeftHeader.style.backgroundColor = previewTable.rows[0].style.backgroundColor;
246
+ tdLeftHeader.style.width = null;
247
+ tdLeftHeader.style.height = null;
248
+ tdLeftHeader.removeAttribute( 'data-x-index' );
249
+ tdLeftHeader.removeAttribute( 'data-wptb-css-td-auto-width' );
250
  if( sectionNumber > 0 && j % tableColumns == 0 ) {
251
  tdLeftHeader.style.borderTopWidth = '5px';
252
  }
256
  if( k < previewTable.rows.length ) {
257
  td = previewTable.rows[k].children[j - sectionNumber*tableColumns].cloneNode( true );
258
  td.style.backgroundColor = previewTable.rows[k].style.backgroundColor;
259
+ td.style.width = null;
260
+ td.style.height = null;
261
+ td.removeAttribute( 'data-x-index' );
262
+ td.removeAttribute( 'data-wptb-css-td-auto-width' );
263
  } else {
264
  td = document.createElement( 'td' );
265
  td.style.borderWidth = '0px';
345
  let rowStyles = window.getComputedStyle( row );
346
  newTd.style.backgroundColor = rowStyles.backgroundColor;
347
  }
348
+ newTd.style.width = null;
349
+ newTd.style.height = null;
350
+ newTd.removeAttribute( 'data-x-index' );
351
+ newTd.removeAttribute( 'data-wptb-css-td-auto-width' );
352
  tr.appendChild( newTd );
353
  }
354
 
373
  }
374
  }
375
 
376
+ function wptb_tdDefaultWidth() {
377
+ let table = document.getElementsByClassName( 'wptb-preview-table' )[0];
378
+ table.mergingСellsHorizontally = false;
379
+ let tds = table.querySelectorAll( 'td' );
380
+ for( let i = 0; i < tds.length; i++ ) {
381
+ if( tds[i].colspan > 1 ) {
382
+ table.mergingСellsHorizontally = true;
383
+ }
384
+ }
385
+
386
+ let wptbTableContainer = document.getElementsByClassName( 'wptb-table-container' )[0];
387
+ let wptbTableContainerWidth = wptbTableContainer.offsetWidth;
388
+
389
+ let td = table.querySelector( 'td' );
390
+ let tdStyleObj = window.getComputedStyle( td, null );
391
+ let tdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );
392
+ let tdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );
393
+ let tdPaddingLeftWidth = tdStyleObj.getPropertyValue( 'padding-left' );
394
+ let tdPaddingRightWidth = tdStyleObj.getPropertyValue( 'padding-left' );
395
+ let tdPaddingCommon = parseFloat( tdPaddingLeftWidth, 10 ) + parseFloat( tdPaddingRightWidth, 10 );
396
+ let tableTdBorderCommonWidth = parseFloat( tdBorderLeftWidth, 10 ) + parseFloat( tdBorderRightWidth, 10 );
397
+ let wptbTableTdsSumMaxWidth = table.dataset.wptbTableTdsSumMaxWidth;
398
+ let wptbFixedWidthSize = table.dataset.wptbFixedWidthSize;
399
+ let wptbCellsWidthAutoCount = table.dataset.wptbCellsWidthAutoCount;
400
+ let styleElementCreate = false;
401
+ let tableTdWidthAuto;
402
+ if( wptbTableTdsSumMaxWidth < wptbTableContainerWidth ) {
403
+ if( wptbCellsWidthAutoCount ) {
404
+ table.style.minWidth = '100%';
405
+ if( table.mergingСellsHorizontally ) {
406
+ table.style.width = null;
407
+ let tableTdsWidthAutoCommon = wptbTableContainerWidth - wptbFixedWidthSize;
408
+ tableTdWidthAuto = tableTdsWidthAutoCommon / wptbCellsWidthAutoCount;
409
+ tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
410
+ styleElementCreate = true;
411
+ } else {
412
+ table.style.width = '100%';
413
+ }
414
+ } else {
415
+ table.style.width = null;
416
+ table.style.minWidth = null;
417
+ table.style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
418
+ }
419
+ } else {
420
+ table.style.maxWidth = null;
421
+ table.style.minWidth = table.dataset.wptbTableTdsSumMaxWidth + 'px';
422
+ table.style.width = null;
423
+ tableTdWidthAuto = '100'
424
+ styleElementCreate = true;
425
+ }
426
+
427
+ let head = document.head;
428
+ if( head ) {
429
+ let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width="true"]' );
430
+ if( cssForTdsWidthAutoOld ) {
431
+ head.removeChild( cssForTdsWidthAutoOld );
432
+ }
433
+ }
434
+
435
+ if( styleElementCreate ) {
436
+ let cssForTdsWidthAuto = document.createElement( 'style' );
437
+ cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );
438
+ cssForTdsWidthAuto.innerHTML = '.wptb-table-container table td[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';
439
+ if( head ) {
440
+ head.appendChild( cssForTdsWidthAuto );
441
+ }
442
+ }
443
+ }
444
  });
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: imtiazrayhan
3
  Tags: table, table builder, drag and drop
4
  Requires at least: 4.9
5
  Tested up to: 5.2
6
- Stable tag: 1.0.0
7
  Requires PHP: 5.6
8
  License: GPL3+
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -54,10 +54,16 @@ That's it. You're done!
54
  == Screenshots ==
55
 
56
  1. Table Builer Interface.
57
- 2. Table Shortcode Popup.
 
58
 
59
  == Changelog ==
60
 
 
 
 
 
 
61
  = 1.0.0 =
62
 
63
  * First Release.
3
  Tags: table, table builder, drag and drop
4
  Requires at least: 4.9
5
  Tested up to: 5.2
6
+ Stable tag: 1.0.1
7
  Requires PHP: 5.6
8
  License: GPL3+
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
54
  == Screenshots ==
55
 
56
  1. Table Builer Interface.
57
+ 2. Cell Management Mode.
58
+ 3. Table Shortcode Popup.
59
 
60
  == Changelog ==
61
 
62
+ = 1.0.1 =
63
+
64
+ * NEW: Column Width Setting.
65
+ * NEW: Row Height Setting.
66
+
67
  = 1.0.0 =
68
 
69
  * First Release.
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 Table Builder Plugin for WordPress.
18
- * Version: 1.0.0
19
  * Author: Imtiaz Rayhan
20
  * Author URI: https://imtiazrayhan.com//
21
  * License: GPL-3.0+
15
  * Plugin Name: WP Table Builder
16
  * Plugin URI: https://wptablebuilder.com/
17
  * Description: Drag and Drop Table Builder Plugin for WordPress.
18
+ * Version: 1.0.1
19
  * Author: Imtiaz Rayhan
20
  * Author URI: https://imtiazrayhan.com//
21
  * License: GPL-3.0+