Advertisement
NikolayPaskulov

Untitled

Nov 14th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. document.getElementById('pokupkiHideEmptyCells').onclick = function () {
  2. var strArray = [],
  3. styleTag = document.getElementById('pokupkiStyle'),
  4. newWrapperWidth = 0,
  5. headerWidth = 0,
  6. widthArray = [];
  7.  
  8. //Проверка дали вече не са скрити колоните
  9. if (this.innerHTML == 'Покажи празните колони') {
  10. styleTag.innerHTML = '';
  11. this.innerHTML = 'Скрии празните колони'
  12. return;
  13. }
  14.  
  15. this.innerHTML = 'Покажи празните колони';
  16. //Проверка за празни колони и оразмеряване на tableHeader
  17. for (var i = 0; i < table.children[0].children.length; i++) {
  18. if (purchFooter[i] == '0.00') {
  19. styleTag.innerHTML += '#main-wrapper .c' + (i + 10) + '{ width:0px; display:none; }';
  20. }
  21. widthArray.push(table.children[0].children[i].offsetWidth);
  22. headerWidth += widthArray[i];
  23. newWrapperWidth += widthArray[i];
  24. if (i == 5) {
  25. strArray.push('#main-wrapper #tableHeader > .table-row > .table-cell:first-child, body #main-wrapper #nameHeader .table-cell:first-child,' +
  26. 'body #main-wrapper #footer > .table-row > .table-cell:first-child { width:' + (headerWidth) + 'px}');
  27. headerWidth = 0;
  28. }
  29. if (i == 12) {
  30. styleTag.innerHTML += '#main-wrapper #tableHeader > .table-row > .table-cell:nth-child(2), #main-wrapper #nameHeader .table-cell:nth-child(2) { width:' + (headerWidth) + 'px}';
  31. headerWidth = 0;
  32. }
  33. if (i == 14) {
  34. styleTag.innerHTML += '#main-wrapper #tableHeader > .table-row > .table-cell:nth-child(3), body #main-wrapper #nameHeader .table-cell:nth-child(3) { width:' + (headerWidth) + 'px}';
  35. }
  36.  
  37. }
  38. //оразмеряване на таблицата
  39. strArray.push('#main-wrapper ,#main-wrapper > .table-row { width:' + (newWrapperWidth + 1) + 'px; }');
  40. for (var z = 0; z < widthArray.length; z++) {
  41. if (z > 5 && z < 13) {
  42. strArray.push('body #main-wrapper #tableHeader > .table-row > .table-cell .c' + (z + 1) +
  43. '{ width: ' + (widthArray[z] / tableHeader.children[0].children[1].offsetWidth * 100).toFixed(2) + '%}');
  44. }
  45. if (z > 13 && z < 16) {
  46. strArray.push('body #main-wrapper #tableHeader > .table-row > .table-cell .c' + (z + 1) +
  47. '{ width: ' + (widthArray[z] / tableHeader.children[0].children[2].offsetWidth * 100).toFixed(2) + '%}');
  48. }
  49. strArray.push('body #main-wrapper #table .c' + (z + 1) +
  50. ', body #main-wrapper #footer .c' + (z + 1) + ', body #main-wrapper #tableHeadersFooter .c' + (z + 1) +
  51. '{ width:' + (widthArray[z] / newWrapperWidth * 100).toFixed(2) + '%; }');
  52. }
  53. strArray.push('#main-wrapper #footer .c8c9 {width: ' + (table.children[0].children[7].offsetWidth * 2 + 1) + 'px}');
  54. strArray.push('#main-wrapper #footer > .table-row:nth-child(3) > .table-cell:nth-child(2) {width: ' + (tableHeader.children[0].children[1].offsetWidth + tableHeader.children[0].children[2].offsetWidth + 1) + 'px}');
  55. strArray.push('@media print { body #main-wrapper > * { font-size:11px; }}');
  56. styleTag.innerHTML += strArray.join('');
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement