Advertisement
Guest User

Untitled

a guest
Feb 4th, 2022
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. /**
  2. * 2017 IQIT-COMMERCE.COM
  3. *
  4. * NOTICE OF LICENSE
  5. *
  6. * This file is licenced under the Software License Agreement.
  7. * With the purchase or the installation of the software in your application
  8. * you accept the licence agreement
  9. *
  10. * @author IQIT-COMMERCE.COM <support@iqit-commerce.com>
  11. * @copyright 2017 IQIT-COMMERCE.COM
  12. * @license Commercial license (You can not resell or redistribute this software)
  13. *
  14. */
  15.  
  16. $(document).ready(function () {
  17.  
  18. //table generator
  19.  
  20. $('#table_generator').on('click', function () {
  21. iqitSizeChartCreateTable();
  22. });
  23.  
  24. });
  25.  
  26.  
  27. function iqitSizeChartCreateTable() {
  28. var no_rows = $('.nrows').val();
  29. var no_col = $('.ncol').val();
  30.  
  31. var tbl = document.createElement('table');
  32. //checking and adding style
  33. //checking which style is selected
  34.  
  35. if ($('.table_bordered').prop('checked')) {
  36. tbl.setAttribute("class", "table table-bordered table-sizegudie table-responsive");
  37. }
  38. if ($('.table_bordered').prop('checked') && $('.table_striped').prop('checked')) {
  39. tbl.setAttribute("class", "table table-striped table-bordered table-sizegudie table-responsive");
  40. }
  41. if ($('.table_striped').prop('checked') && !$('.table_bordered').prop('checked')) {
  42. tbl.setAttribute("class", "table table-striped table-sizegudie table-responsive");
  43. }
  44. if (!$('.table_bordered').prop('checked') && !$('.table_striped').prop('checked')) {
  45. tbl.setAttribute("class", "table table-sizegudie table-responsive");
  46. }
  47.  
  48.  
  49. var tblHead = document.createElement('thead');
  50. tbl.appendChild(tblHead);
  51. var tblrow = document.createElement("tr");
  52. tblHead.appendChild(tblrow);
  53. for (r = 0; r < no_col; r++) {
  54. var tblHeadCell = document.createElement('th');
  55. tblrow.appendChild(tblHeadCell);
  56. var thText = document.createTextNode("th" + r);
  57. tblHeadCell.appendChild(thText);
  58. }
  59. if ($('.header_row').prop('checked')) {
  60. var tblHeadCell = document.createElement('th');
  61. tblHeadCell.className = "nobordered-cell";
  62. tblrow.insertBefore(tblHeadCell, tblrow.firstChild);
  63. var thText = document.createTextNode("");
  64. tblHeadCell.appendChild(thText);
  65.  
  66. }
  67. var tblBody = document.createElement("tbody");
  68. for (var p = 0; p < no_rows; p++) {
  69. // creates a table row
  70. var row = document.createElement("tr");
  71.  
  72. if ($('.header_row').prop('checked')) {
  73. var cell = document.createElement("td");
  74. cell.className = "bordered-cell";
  75. var cellText = document.createTextNode("header");
  76. cell.appendChild(cellText);
  77. row.appendChild(cell);
  78. }
  79. for (var q = 0; q < no_col; q++) {
  80. // Create a <td> element and a text node, make the text
  81. // node the contents of the <td>, and put the <td> at
  82. // the end of the table row
  83. var cell = document.createElement("td");
  84. var cellText = document.createTextNode("cell" + p + "," + q);
  85. cell.appendChild(cellText);
  86. row.appendChild(cell);
  87. }
  88.  
  89. // add the row to the end of the table body
  90. tblBody.appendChild(row);
  91. }
  92. tbl.appendChild(tblBody);
  93. //display table
  94. iqitSizeChartAssignToTinyMce(tbl);
  95. }
  96.  
  97. function iqitSizeChartAssignToTinyMce(content) {
  98. $('.js-chart-content').each(function( ) {
  99. var $container = $(this).parents('.form-group').first();
  100. if ($container.is( ":visible" )){
  101. tinymce.get($container.find('textarea').first().attr('id')).execCommand('mceInsertContent', false, content.outerHTML);
  102. }
  103. });
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement